标题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