7 条题解
-
1马睿 (2024sng28) LV 9 @ 2024-12-20 20:16:22
史上最短12行题解
#include<bits/stdc++.h> using namespace std; int n,m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main() { cin>>n; for(int i=1;i<=12;i++){ if((12+n)%7==5)cout<<i<<endl; n = (m[i]+n)%7; } return 0; }
-
12023-1-13 10:41:46@
可以直接模拟也可以用数学知识,判断x月的13日是不是星期五时,由于离上个月经过了(x-1)月的天数(1月另外算,+(13-1)天),就加(x-1)月的天数,再%7。
int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},w; cin>>w; w+=12; for(int i=1;i<=12;i++){//12个月运行12次 w%=7; if(w==5)cout<<i<<endl;//注意换行 w+=a[i]; } return 0; }
-
12022-1-22 22:54:44@
#include <iostream> using namespace std; int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main(){ int n,w=0,num,j=12; cin>>n; num=n; while(j--){ w++; for(int i=1;i<=a[w];i++,num++){ if(num==8) num=1; if(i==13&&num==5){ cout<<w<<endl; } } } return 0; }
-
02024-12-15 20:50:06@
#include<bits/stdc++.h> using namespace std; int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main(){ int n,w=0,num,j=12; cin>>n; num=n; while(j){ w++; for(int i=1;i<=a[w];i++,num++){ if(num8)num=1; if(i13&&num==5)cout<<w<<endl; } j--; } return 0; }
-
02024-12-15 20:49:47@
#include<bits/stdc++.h> using namespace std; int a[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main(){ int n,w=0,num,j=12; cin>>n; num=n; while(j){ w++; for(int i=1;i<=a[w];i++,num++){ if(num8)num=1; if(i13&&num==5)cout<<w<<endl; } j--; } return 0; }
-
-12024-6-21 19:52:38@
#include <math.h> #include <stdio.h> #include <iostream> #include <string.h> using namespace std; int main() { int l , r , d; cin >> l >> r >> d; int sum = 0; if(l < 2) l = 2; for(int k = 1 ; k <= r ; K++) { int flag = 0; int n = k; while(n) { if(n%10 == d) { flag = 1; break; } n/=10; } if(flag == 1) { n = k; for(int i = 2 ; i*i <= n ; i++) { if(n % i == 0) { flag = 0; break; } } if(flag == 1) sum++; } } cout << sum << endl; return 0; }
-
-12024-6-21 19:52:26@
#include <math.h> #include <stdio.h> #include <iostream> #include <string.h> using namespace std; int main() { int l , r , d; cin >> l >> r >> d; int sum = 0; if(l < 2) l = 2; for(int k = 1 ; k <= r ; K++) { int flag = 0; int n = k; while(n) { if(n%10 == d) { flag = 1; break; } n/=10; } if(flag == 1) { n = k; for(int i = 2 ; i*i <= n ; i++) { if(n % i == 0) { flag = 0; break; } } if(flag == 1) sum++; } } cout << sum << endl; return 0; }
- 1
信息
- ID
- 896
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 2
- 标签
- 递交数
- 161
- 已通过
- 98
- 上传者