FZU 2167 大王叫我来巡山呐(水)

第一篇 先水一题吧

 Problem 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
 
思路:
一周为七天 n/7 则为包含周六日的周数
如果 n+1/7 多出一周 则第n天为周六 
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int coun,ans;
        coun=n/7;
        ans=2*coun;
        if((n+1)/7!=coun)//加一天 多一周 则必然为周六
        ans++;
        cout<<ans<<endl;
    }
    return 0;
}

 

posted @ 2014-08-08 23:57  sola94  阅读(163)  评论(0编辑  收藏  举报