Usaco1.1 friday

/*
ID: ljfcnya1
PROG: friday
LANG: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

using namespace std;

#define REP(i, a, b) for(int i = (a), _end_ = (b);i <= _end_; ++ i)
#define mem(a) memset((a), 0, sizeof(a))
#define str(a) strlen(a)

const int maxn = 10000;

int n, m;

void read(int &x) {
    x = 0;
    char c = getchar();
    while(c < '0' || c > '9')
        c = getchar();
    while(c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
}

int date[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, ans[8];

int main() {
    freopen("friday.in", "r", stdin);
    freopen("friday.out", "w", stdout);
    scanf("%d", &n);
    int today = 0;
    REP(i, 1900, 1900 + n - 1) {
        if((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))
            date[1] = 29;
        else
            date[1] = 28;
        REP(j, 0, 11)   
            REP(k, 1, date[j]) {
                ++today;
                if(k == 13)
                    ++ans[today];
                if(today == 7)
                    today = 0;  
            }
    }
    printf("%d %d", ans[6], ans[7]);
    REP(i, 1, 5)
        printf(" %d", ans[i]);
    puts("");
    return 0;
}


你可能感兴趣的:(usaco)