AOJ

AOJ 0045 Sum and Average

404 Not Found #include <cstdio> int main() { int m, n; int total = 0, ave = 0, row = 0; while(~scanf("%d,%d\n", &m, &n)){ total += m * n; ave += n; row++; } printf("%d\n%d\n", total, (int)(ave / (double)row + 0.5)); return 0; } こういう簡単な問題</cstdio>…

AOJ 0050 Apple and Peach

404 Not Found #include <iostream> #include <vector> #include <string> using namespace std; int main() { string s; vector<int> pe, ap; int n; getline(cin, s); pe.push_back(0); ap.push_back(0); while(n=s.find("peach", pe.back() + 5), ~n) pe.push_back(n); while(n=s.find("a</int></string></vector></iostream>…

AOJ 0064 Secret Number

404 Not Found #include <cstdio> int main(){ int n = 0, sum = 0; char c; while(c = getchar(), ~c){ if('0' <= c && c <= '9'){ n *= 10;n += c - '0'; }else{ sum += n;n = 0; } } printf("%d\n", sum); return 0; }</cstdio>

AOJ 0067 The Number of Island

404 Not Found #include <cstdio> char m[14][14]; int fillaround(int x, int y){ if(!m[x][y]) return 0; else m[x][y] = 0; if(m[x - 1][y + 0]) fillaround(x - 1, y + 0); if(m[x + 1][y + 0]) fillaround(x + 1, y + 0); if(m[x + 0][y - 1]) fillaround(x - 0</cstdio>…

AOJ 0501 Data Conversion

404 Not Found #include <cstdio> #include <map> using namespace std; int main() { int n; while(scanf("%d\n", &n), n){ map<char, char> m; char a, b; for(int i = 0; i < n; i++){ scanf("%c %c\n", &a, &b); m[a] = b; } scanf("%d\n", &n); for(int i = 0; i < n; i++){ scan</char,></map></cstdio>…

AOJ 0084 Search Engine

404 Not Found #include <cstdio> #include <vector> #include <string> using namespace std; int main() { vector<string> v,w; string s(""); char c; while(c = getchar(), ~c){ switch(c){ case ' ': case ',': case '.': if(s != "") v.push_back(s); s = c; v.push_back(s); s = ""; b</string></string></vector></cstdio>…

AOJ 0046 Differential

404 Not Found #include <vector> #include <cstdio> #include <algorithm> using namespace std; int main() { double n; vector<double> v; while(~scanf("%lf", &n)) v.push_back(n); sort(v.begin(), v.end()); printf("%.1lf\n", *v.rbegin() - *v.begin()); return 0; }</double></algorithm></cstdio></vector>

AOJ 0077 Run Length

404 Not Found #include <cstdio> #include <cstring> int main() { char s[101]; while(fgets(s, 101, stdin)){ for(int i = 0, l = strlen(s); i < l; i++){ if(s[i] == '@'){ for(int j = 0; j < s[i + 1] - '0'; j++) putchar(s[i + 2]); i += 2; }else{ putchar(s[i]); }</cstring></cstdio>…

AOJ 0051 Differential II

404 Not Found #include <cstdio> #include <vector> #include <cstdlib> #include <algorithm> using namespace std; int main() { int n; char s[9]; scanf("%d\n", &n); for(int i = 0; i < n; i++){ int max, min; vector<int> v; scanf("%8s", s); for(int j = 0; j < 8; j++) v.push_back(s[j] -</int></algorithm></cstdlib></vector></cstdio>…

AOJ 0028 Mode Value

404 Not Found #include <cstdio> #include <map> #include <vector> #include <algorithm> using namespace std; int main() { map <int, int> m; map <int, vector<int> > l; int n; while(~scanf("%d\n", &n)) m[n]++; for(map<int, int>::iterator it = m.begin(); it != m.end(); it++) l[(*it).second].push_back((*i…</int,></int,></int,></algorithm></vector></map></cstdio>

AOJ 0052 Factorial II

404 Not Found #include <cstdio> int main() { int n, a; while(a = 0, scanf("%d\n", &n), n){ while(n /= 5) a += n; printf("%d\n", a); } return 0; } すいません、解き方ぐぐりました。 階乗の末尾の 0 の個数数学的知識は乏しいのでそれぞれ覚えていくしかな</cstdio>…

AOJ 0049 Blood Group

404 Not Found #include <cstdio> #include <string> #include <map> using namespace std; int main() { char s[3]; map<string, int> m; while(~scanf("%*d,%2s", s)) m[string(s)]++; printf("%d\n%d\n%d\n%d\n", m["A"], m["B"], m["AB"], m["O"]); return 0; }</string,></map></string></cstdio>

AOJ 0031 Weight

404 Not Found #include <cstdio> #include <vector> using namespace std; int main() { int n; while(~scanf("%d\n", &n)){ vector<int> v; for(int i = 512; 1 <= i; i /= 2){ if(n < i) continue; n -= i; v.push_back(i); if(n <= 0) break; } for(int i = v.size() - 1; 0 <</int></vector></cstdio>…

AOJ 0048 Class

404 Not Found #include <cstdio> int main() { float n; int m; const char *rank[] = {"light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"}; while(~scanf("%f\n", &n)){ if(n <= 48</cstdio>…

AOJ 0047 Cup Game

404 Not Found #include <cstdio> #define swp(a,b) a ^= b,b ^= a,a ^= b; int main() { int cups[3] = {1, 0, 0}; unsigned char a, b; while(~scanf("%c,%c\n", &a, &b)) swp(cups[a - 'A'], cups[b - 'A']); printf("%c\n", cups[0] * 'A' + cups[1] * 'B' + cup</cstdio>…

AOJ 0061 Rank Checker

404 Not Found #include <map> #include <vector> #include <cstdio> using namespace std; int main(){ int n, m; map<int, vector<int> > l; vector<vector<int> > v; while(~scanf("%d,%d\n", &n, &m)){ if(!n && !m) break; l[m].push_back(n); } for(map<int, vector<int> >::reverse_iterator rit = l.rbegin(); rit …</int,></vector<int></int,></cstdio></vector></map>

AOJ 0075 BMI

404 Not Found #include <cstdio> int main() { int l; double m, n; while(~scanf("%d,%lf,%lf\n", &l, &m, &n)) if(25.0 <= m/(n*n)) printf("%d\n", l); return 0; }</cstdio>

AOJ 0020 Capitalize

404 Not Found #include <cstdio> int main() { char n; while(~(n = getchar())) putchar('a' <= n && n <= 'z' ? n - 'a' + 'A' : n); return 0; } あまり気合の入らないショートコーディング main(n){while(n=getchar(),~n)putchar(96</cstdio>

AOJ 0066 Tic Tac Toe

404 Not Found #include <cstdio> int main(){ char b[10], a[3][3]; while(~scanf("%9s\n", b)){ char r = 0; for(int i = 0; i < 9; i++) a[i%3][i/3] = b[i]; for(int i = 0, j, f; i < 3; i++){ if(a[i][0] == 's') continue; for(j = 0, f = 1; j < 3; j++) if(</cstdio>…

AOJ 0018 Sorting Five Numbers

404 Not Found #include <cstdio> #include <vector> #include <algorithm> using namespace std; int main(){ vector<int> v(5); for(int i = 0; i < 5; i++) scanf("%d", &v[i]); sort(v.rbegin(), v.rend()); for(int i = 0; i < 5; i++) printf("%d%c", v[i], i-4?' ':'\n'); return 0; }</int></algorithm></vector></cstdio>

AOJ 0025 Hit and Blow

#include <cstdio> int main(){ int a[4], b[4]; while(~scanf("%d %d %d %d\n%d %d %d %d\n", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3])){ int hit = 0, blow = 0; for(int i = 0; i < 4; i++) for(int j = 0; j < 4; j++) if(a[i] == b[j]) if(i =</cstdio>…

AOJ 0029 English Sentence

#include <iostream> #include <string> #include <map> using namespace std; int main(){ string s, max(""); map<string, int> w; map<int, string> x; while(cin>>s){ if(s.size() > max.size()) max = s; w[s]++; } for(map<string, int>::iterator it = w.begin(); it != w.end(); it++) x[(*it).second] = (*it).fir…</string,></int,></string,></map></string></iostream>

AOJ 0026 Dropping Ink

#include <cstdio> int main(){ int x, y, sz, max = 0, cnt = 0; char si[3][3] = {{0, 1, 0}, {1, 1, 1}, {0, 1, 0}}, mi[3][3] = {{1,1,1},{1,1,1},{1,1,1}}, li[5][5] = {{0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}}</cstdio>…

AOJ 0036 A Figure on Surface

404 Not Found #include <cstdio> int main(){ char m[12][12]; char fgr[7][4][4] = { {{1, 1, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, {{1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}, {1, 0, 0, 0}}, {{1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0,</cstdio>…

AOJ 0033 Ball

404 Not Found #include <cstdio> #include <list> using namespace std; int main(){ int n; scanf("%d\n", &n); for(int i = 0, tmp; i < n; i++){ list<int> a, b, c; for(int j = 0; j < 10; a.push_back(tmp), j++) scanf("%d", &tmp); while(!a.empty()){ if(a.front() > </int></list></cstdio>…

AOJ 0017再チャレンジ失敗

前回のコードは少し思い当たる節があったので、1から書きなおしてみたが、これがまたRuntime Errorだとかよく分からないエラーを吐く。もうはやここまでくるとお手上げ感がある。 #include <cstdio> #include <vector> #include <string> using namespace std; int main(){ while(1){</string></vector></cstdio>…

AOJ 0017と0027が通らない

[誤答例]AOJ 0017 Caesar Chipher #include <cstdio> #include <cstring> inline int cmp(char *ha, const char *ne, int len){ for(int i = -128, f = 1; i <= 127; i++, f = 1){ for(int j = 0; j < len; j++) if(ha[j]+i != ne[j]) f = 0; if(f) return i; } return 0; } i</cstring></cstdio>…

AOJ 0013 Switching Railroad Cars

※AOJはショートコーディングをする場ではありません 短縮前 #include <cstdio> #include <vector> int main(){ int n; std::vector<int> v; while(scanf("%d\n", &n)+1){ if(n){ v.push_back(n); }else{ printf("%d\n", v.back()); v.pop_back(); } } return 0; } 短縮後 #include <cstdio></cstdio></int></vector></cstdio>…

AOJ 0011 Drawing Lots

今日はid:kyuridenamidaと延々とリナカフェでcode golfをしたり秋葉原をほっつき歩いたりした。 まだこれからコードを書く。東京タワーとか見に行っても楽しくないしいっその事コーディング合宿って事でもいいんじゃないかって話になってる。初期状態のvを1…

AOJ 1000 A + B Problem

気休め、のはずなのにアホみたいなミスして不要なTLEをしてしまった。 #include <cstdio> int main(){ int a, b; while(scanf("%d %d\n", &a, &b)+1) printf("%d\n", a + b); return 0; }</cstdio>