1.1.3Friday the Thirteenth

  1. /*
  2. ID: awsd1231
  3. PROG: friday
  4. LANG: C++
  5. */
  6. #include<iostream>
  7. #include<cstdio>
  8. usingnamespace std;
  9. constint monthDay[12]={31,0,31,30,31,30,31,31,30,31,30,31};
  10. int main(){
  11. freopen("friday.in","r", stdin);
  12. freopen("friday.out","w", stdout);
  13. int year =1900;
  14. int today =6;
  15. int week[8]={0};
  16. week[6]++;
  17. int n;
  18. cin >> n;
  19. for(int i =0; i != n;++i){
  20. for(int j =0; j !=12;++j){
  21. if(j ==1)
  22. if((year+i)%4==0&&(year+i)%100!=0||(year+i)%400==0)
  23. today =(today +29)%7;
  24. else
  25. today =(today +28)%7;
  26. else
  27. today =(today + monthDay[j])%7;
  28. week[today]++;
  29. // cout << j+2 << "月:" << today << endl;
  30. }
  31. }
  32. week[today]--;
  33. cout << week[6]<<" ";
  34. for(int i =0; i !=5; i++)
  35. cout << week[i]<<" ";
  36. cout << week[5];
  37. cout << endl;
  38. return0;
  39. }
 





你可能感兴趣的:(id)