發表文章

目前顯示的是 2月, 2016的文章

[ZJ]a034: 二進位制轉換

題目: http://zerojudge.tw/ShowProblem?problemid=a034 ------------------------------------------------------------------------------------------------------------------- #include<stdio.h> #include<stdlib.h> #define N 100 int stack[N]; int top=-1; void push(int); int pop(void); void printStack(void); int main(void) { int x,y; while(scanf("%d",&x)!=EOF){ while(x>=0) { y=x%2; push(y); x=x/2; if(x==0) break; } printStack(); printf("\n"); while(top!=-1) {                   top=-1;     } } } void push(int y) { stack[++top]=y; } int pop(void) { return stack[top--]; } void printStack(void) { int i; for(i=top;i>=0;i--) { printf("%d",stack[i]); } }

[ZJ]a024. 最大公因數(GCD)

題目: http://zerojudge.tw/ShowProblem?problemid=a024 ----------------------------------------------------------------------------------------------------------------- #include<stdio.h> #include<stdlib.h> int GCD(int a,int b) { int c; c=a%b; if(c==0) return b; else return GCD(b,c); } int main(void) { int a,b; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d",GCD(a,b)); printf("\n"); } return 0; }

[ZJ]a022: 迴文

題目: http://zerojudge.tw/ShowProblem?problemid=a022 ------------------------------------------------------------------------------------------------------------------ #include<stdio.h> #include<stdlib.h> #include<string.h> #define N 1100 int main(void) { int i,len;//len記字串長度 char str[N]; while(gets(str)){ len=strlen(str);//strlen計算字串長度 for(i=0;i<len/2;i++) { if(str[i]!=str[len-i-1]) { printf("no\n"); break; } } if(i>=len/2) printf("yes\n"); } return 0; }

[ZJ]a015: 矩陣的翻轉

題目: http://zerojudge.tw/ShowProblem?problemid=a015 -------------------------------------------------------------------------------------------------------------------- #include<stdio.h> #include<stdlib.h> #include<string.h> #define N 100 int main(void) { int m,n,i,j; while(scanf("%d %d",&m,&n)!=EOF){ int A[N][N]; int B[N][N]; memset(A,0,sizeof(A)); memset(B,0,sizeof(B)); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",&A[i][j]); } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { B[j][i]=A[i][j]; } } for(i=0;i<n;i++) { for(j=0;j<m;j++) { printf("%d",B[i][j]); printf(" "); } printf("\n"); } printf("\n"); } return 0; }

[ZJ]a009: 解碼器

題目: http://zerojudge.tw/ShowProblem?problemid=a009 -------------------------------------------------------------------------------------------------------------------------- #include<stdio.h> #include<stdlib.h> #include<string.h> #define N 200 int main() { int n; char s[200]; memset(s,' ',sizeof(s)); while(gets(s)) { n=strlen(s); for(int i=0;i<n;i++) printf("%c",s[i]+'*'-'1'); printf("\n"); } return 0; }

[ZJ]a006. 一元二次方程式

題目: http://zerojudge.tw/ShowProblem?problemid=a006 -------------------------------------------------------------------------------------------------------------------- #include <iostream> #include <cmath> using namespace std; int main() {     int a, b, c;       while (cin >>a >>b >>c ){                   if (b*b -4*a*c <0)                        cout << "No real root";           else if (b*b -4*a*c ==0)                  cout <<"Two same roots x=" <<-b /(2*a) ;           else                                     cout << "Two different roots x1=" << (-b + sqrt(b*b-4*a*c)) / (2*a)                    << " , x2=" << (-b - sqrt(b*b-4*a*c)) / (2*a) ;                   cout <<endl ;             } return 0; }

[ZJ]a005: Eva 的回家作業

題目: http://zerojudge.tw/ShowProblem?problemid=a005 ------------------------------------------------------------------------------------------------------------------ #include<stdio.h> #include<stdlib.h> int main(void) { int N,a,b,c,d,r,e,s; while(scanf("%d",&N)!=EOF){ for(int i=1;i<=N;i++) { scanf("%d %d %d %d",&a,&b,&c,&d); if(b - a == c - b) { s = b - a; e = a + 4 * s; printf("%d %d %d %d %d",a,b,c,d,e); } else if(b / a == c / b) { r = b / a; e = a * r * r * r * r; printf("%d %d %d %d %d",a,b,c,d,e); } printf("\n"); } } return 0; }

[ZJd097][UVA10038] Jolly Jumpers

題目: http://zerojudge.tw/ShowProblem?problemid=d097 ----------------------------------------------------------------------------------------------------------------------- #include<cstdio> #define maxn 3000+1 int main() { int n; while(scanf("%d",&n)!=EOF) { int a[maxn] = {0}, y = 0, x = 0, ans = 0, z = 0; scanf("%d",&x); for(int i=1;i<n;i++) { scanf("%d",&y); ans = x-y>=0?x-y:y-x; a[ans] = 1; x = y; } for(int i=1;i<=n-1;i++) { if(!a[i]) { z = 1; break; } } printf("%s\n",!z ? "Jolly" :"Not jolly"); } return 0; }

[ZJd123][UVA11063 ] B2-Sequence

題目: http://zerojudge.tw/ShowProblem?problemid=d123 -------------------------------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; int main() { int b[100],n,T = 1; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) scanf("%d",&b[i]); int a[20001]={0}, z = 1; for(int i=0;i<n;i++) { for(int j=i;j<n;j++) { if(a[b[i]+b[j]] !=0) { z = 0; break; } if(a[b[i]+b[j]] == 0) a[b[i]+b[j]]++; } if(z == 0) break; } printf("Case #%d: It is %s.\n",T++,(z)?"a B2-Sequence":"not a B2-Sequence"); } return 0; }

[ZJ]d562: 山寨版磁力蜈蚣

題目: http://zerojudge.tw/ShowProblem?problemid=d562 ----------------------------------------------------------------------------------------------------------------- #include<cstdio> int main() { int n; while(scanf("%d",&n)!=EOF) { int a[102]={0}; for(int i=0;i<n;i++) scanf("%d",&a[i]); int head = 0,tail = n-1; for(int i=0;i<n;i++) printf("%d ",a[i]); printf("\n"); for(int i=2;i<=n;i++) { if(i % 2 == 0) { head++; for(int j=tail;j>=head;j--) printf("%d ",a[j]); printf("\n"); } else { tail--; for(int j=head;j<=tail;j++) printf("%d ",a[j]); printf("\n"); } } } return 0; }

[ZJ]b682: 高中組第二題-同學早安

題目: http://zerojudge.tw/ShowProblem?problemid=b682 ----------------------------------------------------------------------------------------------------------------- #include<cstdio> int main(void) { int H1,M1,H2,M2; while(scanf("%d%d%d%d",&H1,&M1,&H2,&M2)!=EOF) { int a = 0, b = 0; if(H2 > H1) a = H2 - H1; else a = 24 - H1 + H2; if(M2 >= M1) b = M2 - M1; else { a = a -1; b = 60 - M1 + M2; } if(H1 == H2) { if(M1 > M2) a = 23; else a = 0; } printf("%d %d\n",a,b); } return 0; }

[ZJ]a307: NOIP2011 1.数字反转

題目: http://zerojudge.tw/ShowProblem?problemid=a307 ---------------------------------------------------------------------------------------------------------------- #include <bits/stdc++.h> using namespace std ; int main() { long long int in0 ;   while (cin >>in0 ){   if(in0 < 0)   {   in0 = -in0; printf("-"); } if (in0==0 ){   cout << 0 ;   break; }   while (in0%10==0&&in0>0){   in0/=10;   }   while (in0){   cout <<in0%10 ;   in0/=10 ; } cout <<endl ; } return 0; }

[ZJc084][UVA275] - Expanding Fractions

題目: http://zerojudge.tw/ShowProblem?problemid=c084 ------------------------------------------------------------------------------------------------------------------ #include<bits/stdc++.h> #define maxn 1000+1 using namespace std; int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF && a || b) { int x = 0,s1[maxn]={0},s2[maxn]={0}, len = 0, z = 0; s2[0] = a; while(1) { z = 0; x++; s1[x] = a * 10 / b; a = (a * 10) % b; s2[x] = a; if(!a) { len = -1; break; } for(int i=0;i<x;i++) { if(s2[x] == s2[i]) { z = 1; len = x - i; break; } } if(z) break; } printf("."); for(int i=1;i<=x;i++) { printf("%d",s1[i]); if((i + 1) % 50 == 0) printf("\n"); } printf("\n"); if(len > 0) printf("The last %d digits repeat forever.\n",len); if(len == -1)

[ZJd044][UVA640] Self Numbers

題目: http://zerojudge.tw/ShowProblem?problemid=d044 ----------------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> #define maxn 1000000+1 using namespace std; int a[maxn] = {0}; int main() { int x = 0, j = 0; for(int i=1;i<maxn;i++) { j = i; if(a[j] == 0) { while(1) { x = j; while(j > 0) { x += j % 10; j = j / 10; } if(x < maxn && a[x] == 0) { a[x] = 1; j = x; } else break; } } } for(int i=1;i<maxn;i++) if(a[i] == 0) printf("%d\n",i); return 0;  }

[ZJc061][UVA530] - Binomial Showdown

題目: http://zerojudge.tw/ShowProblem?problemid=c061 -------------------------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; typedef long long int LL; int main() { LL n,m; while(scanf("%lld%lld",&n,&m)!=EOF && n || m) { if(2 * m > n) m = n - m; LL ans = 1; for(int i=1;i<=m;i++) ans = ans * (n - m  + i) / (i); //乘一個數就除一個數 printf("%lld\n",ans); } return 0; }

[ZJ]a858: 數三角形

題目: http://zerojudge.tw/ShowProblem?problemid=a858 -------------------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; int main() { int n;     while(scanf("%d", &n)!=EOF) {     int ans = n*(n-1)*(n-2)/2/3;     int temp = 0;     for(int i = 0; i < n; i++)     {         int r = 0, b = 0;        for(int j = 0; j < n; j++)         {             int p;             scanf("%d", &p);             if( p == 1 ) r++;             if( p == 2 ) b++;         }         temp += r*b;     }     ans -= temp/2;     printf("%d\n", ans); } return 0; }

[ZJa130][UVA12015] Google is Feeling Lucky

題目: http://zerojudge.tw/ShowProblem?problemid=a130 -------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> #define maxn 100+1 using namespace std; int main() { int T,j=1; scanf("%d",&T); while(T--) { char s[15][maxn]; int r[15] = {0},maxi = -1; for(int i=0;i<10;i++) { scanf("%s %d",s[i],&r[i]); maxi = max(maxi,r[i]); } printf("Case #%d:\n",j++); for(int i=0;i<10;i++) { if(maxi == r[i]) printf("%s\n",s[i]); } } return 0; }

[ZJ]d491: 我也愛偶數 (swap 版)

題目: http://zerojudge.tw/ShowProblem?problemid=d491 ------------------------------------------------------------------------------------------------------------- #include<cstdio> typedef long long int LL; int main() { LL a,b; while(scanf("%lld%lld",&a,&b)!=EOF) { if(a > b) { LL t = 0; t = a; a = b; b = t; } if(a%2!=0) a++; LL sum = 0; for(LL i=a;i<=b;i=i+2) { sum = sum + i; } printf("%lld\n",sum); } return 0; }

[ZJ]b524: 先別管這個了,你聽過yee嗎?

題目: http://zerojudge.tw/ShowProblem?problemid=b524 ----------------------------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> #define maxn 100000 using namespace std; int main() { char yee[maxn]; while(scanf("%s",&yee)!=EOF) { int sum=0,a=0; for(int i=0;yee[i]!=0;i++) { if(yee[i]=='y') { sum += abs(i-a); a+=3; } } printf("%d\n",sum); } return 0; }

[ZJa135][UVA12250] Language Detection

題目: http://zerojudge.tw/ShowProblem?problemid=a135 -------------------------------------------------------------------------------------------------------------------------- #include<iostream> using namespace std; string s[] = { "ENGLISH","SPANISH","GERMAN","FRENCH","ITALIAN","RUSSIAN" }; string he[] = { "HELLO","HOLA","HALLO","BONJOUR","CIAO","ZDRAVSTVUJTE" }; int main() {   int T = 0;   string a;   while( cin >> a && a != "#" ) {     int z = 0;     for(int i=0;i<6;i++) {       if(he[i] == a) {         printf("Case %d: %s\n", ++T,s[i].c_str());         z = 1;         break;       }     }     if(!z)       printf("Case %d: UNKNOWN\n", ++T);   }   return 0; }

[ZJ]d478: 共同的數 - 簡易版

題目: http://zerojudge.tw/ShowProblem?problemid=d478 ---------------------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> #define maxn 10000+1 using namespace std; int a[10001],b[10001]; int main() {   int n,m;   scanf("%d %d",&n,&m);   while(n--) {     int ans = 0;     for(int j=0;j<m;j++)       scanf("%d",&a[j]);     for(int j=0;j<m;j++)       scanf("%d",&b[j]);         int k=0;     for(int j=0;j<m;) {       if (a[j]==b[k]) {         ans++;         j++;         k++;                     }   else if (a[j]>b[k])         k++;                 else         j++;                     if (k==m)         break;                   }     printf("%d\n",ans);             } return 0; }

[ZJ]a524: 手機之謎

題目: http://zerojudge.tw/ShowProblem?problemid=a524 -------------------------------------------------------------------------------------------------------------- #include<cstdio> #include<cstring> int a[10]={0},b[10]={0},n; void dfs(int x) {     int i;     if(x==n){         for(i=0;i<n;i++)             printf("%d",a[i]);         printf("\n");         return;     }     for(i=n;i>=1;i--){         if(b[i]==0){             b[i]=1;             a[x]=i;             dfs(x+1);             b[i]=0;         }     } } int main() { while(scanf("%d",&n) == 1) { memset(b,0,sizeof(b)); dfs(0); } return 0; }

[ZJ] a693. 吞食天地

題目: http://zerojudge.tw/ShowProblem?problemid=a693 ------------------------------------------------------------------------------------------------ #include<bits/stdc++.h> using namespace std; typedef long long int LL; LL a[100001]; LL sum[100001]; int main() {   int n,m;   while (scanf("%d",&n)==1){     scanf("%d",&m);         for(int i=0;i<n;i++)       scanf("%lld",&a[i]);           sum[0]=0;     for(int i=0;i<n;i++){       sum[i+1]=sum[i]+a[i];           }       int x,y;     for(int i=0;i<m;i++){       scanf("%d %d",&x,&y);       printf("%lld\n",sum[y]-sum[x-1]);     }               }   return 0; }

[ZJ]d139: Compressed String

題目: http://zerojudge.tw/ShowProblem?problemid=d139 ---------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; int main() { string s; while(cin >> s) { int ans = 0; for(int i=0;i<s.length();i++) { ans = 1; while((i+1) < s.length() && s[i] == s[i+1]) ans++, i++; if(ans > 2) cout << ans << s[i]; else if(ans == 2) cout << s[i] << s[i]; else cout << s[i]; } puts(""); } return 0; }

[ZJ]b373: [福州19中]车厢重组

題目: http://zerojudge.tw/ShowProblem?problemid=b373 --------------------------------------------------------------------------------------------------- #include<cstdio> #define maxn 10000+1 int main() { int n; while(scanf("%d",&n)!=EOF) { int a[maxn] = {0},ans = 0,temp = 0; for(int i=0;i<n;i++) scanf("%d",&a[i]); for (int i = n - 1; i > 0; --i) { for (int j = 0; j < i; ++j) { if (a[j] > a[j + 1]) { temp = a[j]; a[j] = a[j+1]; a[j+1] = temp; //swap(a[j], a[j + 1]); ans++; }                 } }         printf("%d\n",ans); } return 0; }

[CF]600B - Queries about less or equal elements

題目: http://codeforces.com/problemset/problem/600/B ---------------------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; #define MAXN 200010 int main() {     int n,m;     while(scanf("%d%d",&n,&m)!=EOF)     {         int a[MAXN] = {0},i=0,c = 0,*sum,b[MAXN] = {0};         for(i=0;i<n;i++)             scanf("%d",&a[i]);         sort(a,a+n);         for(int i=0;i<m;i++)             scanf("%d",&b[i]);         for(int i=0;i<m;i++)         {             sum = upper_bound(a,a+n,b[i]);             printf("%d%c",sum-a,i==m-1?'\n':' ');         }     }     return 0; }

[CF]581B - Luxurious Houses

題目: http://codeforces.com/problemset/problem/581/B ----------------------------------------------------------------------------------- #include<bits/stdc++.h> #define N 100050 using namespace std; int main(void) {     int n;     while(scanf("%d",&n)!=EOF)     {         int a[N]={0},mxn[N]={0};         for(int i=0;i<n;i++)             scanf("%d",&a[i]);         for(int i=n-1;i>=1;i--)             mxn[i] = max(mxn[i+1],a[i]);         for(int i=0;i<n;i++)             printf("%d ",max(0,mxn[i+1]-a[i]+1));         printf("\n");     }         return 0; }

[CF]581A - Vasya the Hipster

題目: http://codeforces.com/problemset/problem/581/A ------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; int main(void) {     int a,b;     while(scanf("%d%d",&a,&b)!=EOF)     {         int mxn = 0, mn = 0;         if(a == b)             printf("%d %d\n",a,0);         else         {             mxn = max(a,b);             mn = min(a,b);             mxn -= mn;             printf("%d %d\n",mn,mxn/2);         }     }     return 0;  }

[CF]580A - Kefa and First Steps

題目: http://codeforces.com/problemset/problem/580/A ------------------------------------------------------------------------------------------- #include<iostream> #include<cstdio> using namespace std; int main(void) {     int n;     while(scanf("%d",&n)!=EOF)     {     int x = 0,y = 0,mx = 1,cnt = 1;     for(int i=0;i<n;i++)     {         scanf("%d",&x);         if(x>=y && i!=0)         {             cnt++;         }           else             cnt = 1;         if(cnt > mx)             mx = cnt;         y = x;     }       cout << mx << endl; } return 0; }

[CF]510A - Fox And Snake

題目: http://codeforces.com/problemset/problem/510/A ------------------------------------------------------------------------------------------------- #include<cstdio> #include<cstdlib> #include<cstring> #define N 100 int main(void) {     long int n,m;     while(scanf("%d%d",&n,&m)!=EOF)     {         int x[N][N];         memset(x,0,sizeof(x));         for(int i=1;i<=n;i++)         {             for(int j=1;j<=m;j++)             {                               if(i%4==0 && j!=1)                 {                     printf(".");                 }                 else if(i%2==0 && i%4!=0 && j!=m)                 {                     printf(".");                 }                 else                 {                     printf("#");                 }                             }             printf("\n");         }     }     return 0; }

[CF]495A - Digital Counter

題目: http://codeforces.com/problemset/problem/495/A ---------------------------------------------------------------------------------------------------- #include <cstdio> int main() {       int ara[]={2,7,2,3,3,4,2,5,1,2};       int a;       while(scanf("%d",&a)!=EOF)         printf("%d\n",ara[a%10]*ara[(a/10)%10]);     return 0; }

[ZJ]d212: 東東爬階梯

題目: http://zerojudge.tw/ShowProblem?problemid=d212 --------------------------------------------------------------------------------- #include<cstdio> typedef long long int LL; int main() { int n; while(scanf("%d",&n)!=EOF) { LL a = 1, b = 2, x = a + b; for(int i=3;i<=n;i++) { x = a + b; a = b; b = x; } if(n == 1) printf("%lld\n",a); else if(n == 2) printf("%lld\n",b); else printf("%lld\n",x); } return 0; }

[ZJ]b112: 高中運動會

題目: http://zerojudge.tw/ShowProblem?problemid=b112 ------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; int gcd(int a,int b) { int ans  = 0; while(b != 0) { ans = a % b; a = b; b = ans; } return a; } int main() { int n; while(scanf("%d",&n)!=EOF) { int a,b; scanf("%d",&a); while(n-->1) { scanf("%d",&b); a = gcd(a,b); } printf("%d\n",a); } return 0; }

[ZJd658[UVA11636] Hello World!

題目: http://zerojudge.tw/ShowProblem?problemid=d658 --------------------------------------------------------------------------------------------------- #include<cstdio> #include<cmath> int main() { int n,T=1; while(scanf("%d",&n) == 1 && n > 0) printf("Case %d: %d\n",T++,(int)ceil(log2(n))); return 0; }

[ZJ] a020. 身分證檢驗

題目: http://zerojudge.tw/ShowProblem?problemid=a020 ----------------------------------------------------------------------------------------------- #include<cstdio> #include<cstdlib> #include<cstring> int data[100]={0}; void dat(void); int main() { char s[15]; dat(); memset(s,' ',sizeof(s)); while(scanf("%s",&s)!=EOF) { int x[15]={0},ch=0,i=0,j=0,sum=0; ch=s[0]; for(i=1;i<10;i++) x[i]=s[i]-48; ch=data[s[0]]; // printf("%d\n",ch); sum=(ch/10) + (ch%10)*9 + x[9]; j=8; for(i=1;i<=8;i++) { sum=sum+x[i]*j; j--; } if(sum%10 == 0) printf("real\n"); else printf("fake\n"); } return 0; } void dat(void) { int i=0,j=10; for(i=65;i<=90;i++) { data[i]=j; if(i==73) { data[i]=34; continue; } else if(i==79) { data[i]=35; continue; } else if(i==87) { data[i]=32; continue; } else if(

[ZJ]b681: 高中組第一題-山洞探險

題目: http://zerojudge.tw/ShowProblem?problemid=b681 ---------------------------------------------------------------------------------------- #include<cstdio> int main(void) { long long int L; while(scanf("%lld",&L)!=EOF) { printf("%lld\n",(L>0)?L*2-1:L*2*-1); } return 0; }

[ZJ]b513: 判斷質數-商競103

題目: http://zerojudge.tw/ShowProblem?problemid=b513 -------------------------------------------------------------------------------------------- #include<cstdio> #include<cmath> int isprime(int n) { if(n == 2) return 1; int x = 2, flag = 1; while(x <= sqrt(n)) { if(!(n%x)) { flag = 0; break; } x++; } return flag; } int main() { int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); printf("%c\n",isprime(n)?'Y':'N'); } return 0; }

[ZJ]d478: 共同的數 - 簡易版

題目: http://zerojudge.tw/ShowProblem?problemid=d478 ----------------------------------------------------------------------------------------- #include<bits/stdc++.h> #define maxn 10000+1 using namespace std; int a[10001],b[10001]; int main() {   int n,m;   scanf("%d %d",&n,&m);   while(n--) {     int ans = 0;     for(int j=0;j<m;j++)       scanf("%d",&a[j]);     for(int j=0;j<m;j++)       scanf("%d",&b[j]);         int k=0;     for(int j=0;j<m;) {       if (a[j]==b[k]) {         ans++;         j++;         k++;                     }   else if (a[j]>b[k])         k++;                 else         j++;                     if (k==m)         break;                   }     printf("%d\n",ans);             } return 0; }

[ZJ]b581: 一串加

題目: http://zerojudge.tw/ShowProblem?problemid=b581 ----------------------------------------------------------------------------------------- #include<cstdio> #define maxn 1000+1 typedef long long int LL; int main() { int T; scanf("%d",&T); while(T-->0) { LL a = 0,ans = 0; do{ scanf("%lld",&a); ans = ans + a; }while(getchar()!='\n'); printf("%lld\n",ans); } return 0; }

[ZJd235][UVA10929] You can say 11

題目: http://zerojudge.tw/ShowProblem?problemid=d235 ------------------------------------------------------------------------------------------------------------ #include<bits/stdc++.h> using namespace std; int main() { string s; while(cin >> s) { if(s == "0")break; int a = 0, b = 0; for(int i=0;i<s.length();i++) { if(i % 2 == 0) a = a + (s[i] - '0'); else b = b + (s[i] - '0'); } if((a - b) % 11 == 0) cout << s <<" is a multiple of 11.\n"; else cout << s <<" is not a multiple of 11.\n"; } return 0; }

[ZJ]b762: 英國聯蒙

題目: http://zerojudge.tw/ShowProblem?problemid=b762 ======================================================================== #include<bits/stdc++.h> using namespace std; int main() { int n; while(scanf("%d",&n)!=EOF) { string s[45]; int kill = 0, flag_kill = 0, die = 0, assist = 0; for(int i=0;i<n;i++) { cin >> s[i]; if(s[i] == "Get_Kill") { kill++; flag_kill++; switch(flag_kill) { case 1: printf("You have slain an enemie.\n"); break; case 2: printf("You have slain an enemie.\n"); break; case 3: printf("KILLING SPREE!\n"); break; case 4: printf("RAMPAGE~\n"); break; case 5: printf("UNSTOPPABLE!\n"); break; case 6: printf("DOMINATING!\n"); break; case 7: printf("GUALIKE!\n"); break;

[ZJ]b516: 凱撒密碼

題目: http://zerojudge.tw/ShowProblem?problemid=b516 -------------------------------------------------------------------------------------------------------------------------- #include<cstdio> #include<cstring> int main() { int T; scanf("%d",&T); while(T--) { char s[15]; memset(s,' ',sizeof(s)); scanf("%s",&s); int len = strlen(s); for(int i=0;i<len;i++) { if(s[i] == 'X') printf("A"); else if(s[i] == 'Y') printf("B"); else if(s[i] == 'Z') printf("C"); else printf("%c",s[i]+3); } printf("\n"); } return 0; }