- Problem A. Number Theory Problem
- #include <iostream>
- using namespace std;
- const int maxn = 1e6+10;
- typedef long long ll;
- int T,N;
- int sec[maxn];
- void init(){
- ll cur = 1;
- for(int i = 1;i<=1e5+10;i++){
- cur = cur*2%7;
- if((cur-1+7)%7 == 0) sec[i] = sec[i-1]+1;
- else sec[i] = sec[i-1];
- }
- }
- int main(){
- init();
- cin>>T;
- int kase = 0;
- while(T--){
- printf("Case #%d:",++kase);
- cin>>N;
- printf("%d\n",sec[N]);
- }
- return 0;
- }
- Problem L. World Cup
- #include <iostream>
- #include <cstring>
- using namespace std;
- int T;
- int a,b,c,d;
- int sc[15][15][15][15];
- int A[3] = {3,1,0},B[3] = {0,1,3};
- void init(){
- memset(sc,0,sizeof sc);
- int t1,t2,t3,t4;
- for(int i = 0;i<3;i++){
- for(int j = 0;j<3;j++){
- for(int k = 0;k<3;k++){
- for(int l =0;l<3;l++){
- for(int m = 0;m<3;m++){
- for(int n = 0;n<3;n++){
- t1 = A[i]+A[j]+A[k];
- t2 = B[i]+A[l]+A[m];
- t3 = B[j]+B[l]+A[n];
- t4 = B[k]+B[m]+B[n];
- sc[t1][t2][t3][t4]++;
- }
- }
- }
- }
- }
- }
- }
- int main(){
- init();
- cin>>T;
- int kase = 0;
- while (T--){
- printf("Case #%d:",++kase);
- cin>>a>>b>>c>>d;
- if(a>9||b>9||c>9||d>9) puts("Wrong Scoreboard");
- else if(sc[a][b][c][d] == 1) puts("Yes");
- else if(sc[a][b][c][d]>1) puts("No");
- else puts("Wrong Scoreboard");
- }
- return 0;
- }
来源: http://www.bubuko.com/infodetail-3226978.html