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. }

来自为知笔记(Wiz)

时间: 2024-11-06 12:49:17

1.1.3Friday the Thirteenth的相关文章

USACO。s1.1.3Friday the Thirteenth(数组)

题意:计算n年里的12 * n个月里,每个月的13号落在周日到周六的次数. 思路&易错点:两个数组,一个数组1代表月份,一个数组2代表星期几,天数 % 7作为数组2的下标,自增.判断是否为闰年.某年的1月1号是周m,下一年的1月1号是周m + 1(闰年的话就m + 2,这个是开始时错了,找了几百年bug),就可以得到下一年的1月1号代表周几,继续mod. 代码如下: /* TASK:friday LANG:C++ ID:huibaochen */ #include <iostream>

SDUT 1941-Friday the Thirteenth(水)

Friday the Thirteenth Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Is Friday the 13th really an unusual event? That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, w

USACO Section 1.1-3 Friday the Thirteenth

Friday the Thirteenth 黑色星期五 13号又是一个星期五.13号在星期五比在其他日子少吗?为了回答这个问题,写一个程序,要求计算每个月的十三号落在周一到周日的次数. 给出N年的一个周期,要求计算1900年1月1日至1900+N-1年12月31日中十三号落在周一到周日的次数,N为正整数且不大于400. 注意,开始今年是一千九百年,不是1990 这里有一些你要知道的: 1.1900年1月1日是星期一. 2.4,6,11和9月有30天.其他月份除了2月都有31天.闰年2月有29天,

【USACO1.1.3】Friday the Thirteenth

Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13t

USACO 1.1 Friday the Thirteenth

Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13t

1.1.5 PROB Friday the Thirteenth

Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13t

Thirteenth scrum meeting 2015/11/11

发布bug整理集结: 手机用户体验优化优化: (1)主界面和课程界面的字体规格以及界面结构不同 (2)课程图片的大小格式不统一,造成美观下降 ( 3 )按钮的位置不美观 平板用户体验: (1)Tab键在平板上,基本上特别不好按,需要很小心的按才能按到,不然就会按到下方课程 (2)Tab之间下方的滑动显示模块不知道是不是只有那么多,在平板用户中显示就是缺失了一块. (3)崩了 点击一些视频的时候会出现崩的情况 例子:计算机网络实验-实验10 总结:目前还有出现不经意间崩掉的情况,那种情况还没有找到

OJ刷题---1.1.3 Friday the Thirteenth 黑色星期五

题目要求: 输入代码: #include<iostream> #include<stdio.h> #include<cstdlib> using namespace std; int month[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31}; int ans[8]= {0}; int n,end; void work(int n) { int y,m,d,i; int w=1; y=1900; end=y+n-1; m=d=1

Journal entry of the thirteenth chapter to chapter seventeenth

第十三章: 软件测试的意义在于: a.     发现软件错误: b.     有效定义和实现软件成分由低层到高层的组装过程: c.     验证软件是否满足任务书和系统定义文档所规定的技术要求: d.     为软件质量模型的建立提供依据. 因软件测试在软件开发过程中必不可少,所以,软件测试的方法固然也会很多,我们掌握的知识有限,每一种方法有其的优于劣,是不是一个软件用一个方法去测试就好了,还是说可以要用多个方法来测试,那么具体确定多少个方法,这个我们该如何去确定? 第十四章: 程序=数据结构+