E - easy problem
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Submit
Status
Practice
FZU 2167
Description
大师兄在取得真经后,每天详读经书,认真完成读书笔记,理论联系实际,不断提高实践能力。假设大师兄开始修炼的第一天是星期一,至今已经修炼了N天,那么有多少天是星期六或者星期日,大师兄还在修炼呢?
Input
每组输入数据包含一个整数N(0<N<100,000)。
Output
对每组输入数据,输出一行,仅包含一个整数,表示这N天中是星期六或者星期日的天数。
Sample Input
5
6
7
12
13
14
Sample Output
0
1
2
2
3
4
思路:修炼时,遇到周六或周日,总数就加一,也就是说完整的一周,可以使总数加二
一开始我想用筛法打表,后来发现还没有直接计数效率高
代码
#include<cstdio>
#include<stack>
#include<cstring>
#include<cctype>
#include<cstdlib>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int num=0;
if(n%7!=n)//如果n>=7
{
num=(n/7)*2;
n=n%7;
}
if(n%6!=n)//如果n经过上一处理后,n=6
num++;
printf("%d\n",num);
}
}