USACO--1.1Friday the Thirteenth+简单模拟
来源:互联网 发布:黑豹js防水材料价格 编辑:程序博客网 时间:2024/06/03 11:18
n只有400,所以可以直接暴力模拟。
因为一个小问题卡了很久。。。。。。
代码如下:
/*ID: 15674811LANG: C++TASK: friday*/#include<iostream>#include<cstdio>#include<cstring>#include<fstream>using namespace std;bool is_leap(int year){ if(year%4==0&&year%100!=0) return 1; if(year%400==0) return 1; return 0;}int main(){ int day[15]={31,31,28,31,30,31,30,31,31,30,31,30,31}; ofstream fout("friday.out"); ifstream fin("friday.in"); int n; int week[10]; while(fin>>n) { int tmp=3; //记录前面那个月的13号是星期几 memset(week,0,sizeof(week)); for(int year=1900;year<1900+n;year++) { for(int j=1;j<=12;j++) { int d; d=day[j-1]; if(j==3&&is_leap(year)) d=29; int t=(d%7+tmp)-((d%7+tmp)/7)*7; if(t==0) t+=7; week[t]++; tmp=t; } } fout<<week[6]<<" "<<week[7]<<" "; for(int i=1;i<5;i++) fout<<week[i]<<" "; fout<<week[5]<<endl; } return 0;}
1 0
- USACO--1.1Friday the Thirteenth+简单模拟
- 【USACO-Chapter1-1.1】【模拟】Friday the Thirteenth
- USACO 1.1.3 - Friday the Thirteenth(模拟)
- USACO 1.1-Friday the Thirteenth
- usaco 1.1:Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- usaco/1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO 1.1 Friday the Thirteenth
- USACO 1.1-Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth (friday)
- USACO 1.1 Friday the Thirteenth (friday)
- Friday the Thirteenth(USACO)
- usaco--Friday the Thirteenth
- [USACO] Friday the Thirteenth
- usaco Friday the Thirteenth
- USACO Friday the Thirteenth
- struct 与class的关系
- NSNotificationCenter 通知传值
- VC开发过程中数据类型不兼容的问题
- poj2377 最小生成树
- Android ViewPager 仿照微信Tab
- USACO--1.1Friday the Thirteenth+简单模拟
- CentOS提示 -bash: patch: command not found 解决办法
- android中OnGestureListener和回调函数的应用
- android系统体系结构
- 2015年寒假阅读书单
- leetcode Intersection of Two Linked Lists
- oracle sql查询使用函数
- oracle中trim,ltrim,rtrim函数用法
- java多态学习