当前位置 博文首页 > 美迪的麦柯的博客:Java大王叫我来巡山呐

    美迪的麦柯的博客:Java大王叫我来巡山呐

    作者:[db:作者] 时间:2021-08-17 21:39

    标题Problem C: 大王叫我来巡山呐

    Time Limit: 1 Sec Memory Limit: 128 MB

    Description

    大师兄在取得真经后,每天详读经书,认真完成读书笔记,理论联系实际,不断提高实践能力。假设大师兄开始修炼的第一天是星期一,至今已经修炼了N天,那么有多少天是星期六或者星期日,大师兄还在修炼呢?

    Input

    输入数据包含多组,每组输入数据包含一个整数N(0 < N < 10,000)。

    Output

    对每组输入数据,输出一行,仅包含一个整数,表示这N天中是星期六或者星期日的天数。

    Sample Input Copy

    5
    6
    7
    12
    13

    Sample Output Copy

    0
    1
    2
    2
    3

    Java代码:

    import java.util.*;
    public class Main{
    
    public static void main(String[] args) {
            Scanner sc=new Scanner(System.in);
            while(sc.hasNext())
            {
            int N=sc.nextInt();
            int t1=N/7;
            int num=N%7;
            int t2;
            if(num<6) 
           		t2=0;
            else  if (num>5&&num<7) 
            	t2=1;
            else  
                t2=2;
            int t=2*t1+t2;
            
            System.out.println(t);
             }
             
        }
    }
    

    运行结果:

      	Problem: XXXX
        User: XXXXXXXXXXX
        Language: Java
        Result: Accepted
        Time:117 ms
        Memory:10240 kb
    
    cs
    下一篇:没有了