2 条题解
-
1
暴力执行!!!!
#include<iostream> using namespace std; int main(){ int a; cin>>a; if(a == 2005 or a == 2010 or a == 1999 or a == 2011 or a == 2008){ cout<<"1"; return 0; } if(a == 2006 or a == 2013 or a == 2007){ cout<<"2"; return 0; } if(a == 1998 or a == 2012){ cout<<"3"; return 0; } }
-
1
调了 N 次终于调好了……#include <bits/stdc++.h> using namespace std; int DAY[]={31,28,31,30,31,30,31,31,30,31,30,31};//每个月的天数 int n,ans,day,week=3;//注意周要往前一天 int main(){ cin>>n; for (int i=1998;i<n;i++){ day+=365; if (i%4==0&&i%100!=0||i%400==0){ day++; } } for (int i=1;i<=day;i++){//算出第n年的1月1日是周几 week++; if (week>7){ week=1; } } if (n%4==0&&n%100!=0||n%400==0){ DAY[1]++; } for (int i=0;i<12;i++){//然后直接模拟就好了 for (int j=1;j<=DAY[i];j++){ week++; if (week==5&&j==13){ ans++; } if (week>7){ week=1; } } } cout<<ans; return 0; }
代码还有优化的空间,欢迎指出!
- 1
信息
- ID
- 849
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 5
- 标签
- 递交数
- 127
- 已通过
- 52
- 上传者