PKU70問達成
3425
構造体使って初めて通した。
できる問題のはばが広がった気がする。
#include <cstdio> #include <map> using namespace std; struct ac { int anum, cost; }; int main() { int N; int q, a, x; map<int, ac> m; scanf("%d",&N); for (int i=0; i<N; i++) { scanf("%d%d%d",&q,&a,&x); if (m.find(q)==m.end()) { if (a == 0) { m[q].cost = 10; } else if (a == 1 && x == 0) { m[q].cost = 20; m[q].anum = 1; } else if (a == 1 && x == 1) { m[q].cost = 40; m[q].anum = 1; } } else { if (a == 0) { m[q].cost += 10; } else if (a == 1 && x == 0) { m[q].cost += 20 + m[q].anum * 10; m[q].anum++; } else if (a == 1 && x == 1) { m[q].cost += 40 + m[q].anum * 10; m[q].anum++; } } } map<int, ac>::iterator it; int res = 0; for (it=m.begin(); it!=m.end(); it++) res += (*it).second.cost; printf("%d\n",res); }
3173
やるだけ
#include <cstdio> #include <vector> using namespace std; int main() { int N, S; scanf("%d%d",&N,&S); vector<vector<int> > tri; for (int i=1; i<=N; i++) { vector<int> ed; for (int j=0; j<i; j++) { ed.push_back(S++); if (S == 10) S = 1; } tri.push_back(ed); } for (int i=0; i<N; i++) { for (int j=0; j<i; j++) printf(" "); for (int j=i; j<N-1; j++) { printf("%d ", tri[j][i]); } printf("%d\n", tri[N-1][i]); } }
2027
1000と同じぐらい簡単
#include <cstdio> int main() { int n, X, Y; scanf("%d", &n); for (int i=0; i<n; i++) { scanf("%d%d", &X, &Y); if (X >= Y) printf("MMM BRAINS\n"); else printf("NO BRAINS\n"); } }
2017
書くだけ
#include <cstdio> int main() { int n, s, t, old_t; while (scanf("%d",&n)&&n!=-1) { old_t = 0; int res = 0; for (int i=0; i<n; i++) { scanf("%d%d",&s,&t); res += s*(t-old_t); old_t = t; } printf("%d miles\n",res); } }
2136
また出力などなどで苦しめられた問題。
結局自分のコード(コメントアウト)は通らなかった・・・原因がわからない。
// #include <iostream> // #include <vector> // #include <cstring> // using namespace std; // int main() // { // vector<int> hist(26, 0); // string in; // int m = 0; // for (int ix=0; ix<4; ix++) { // getline(cin, in); // for (int i=0; i<in.length(); i++) { // if (isalnum(in[i])) { // hist[in[i]-'A']++; // if (hist[in[i]-'A'] > m) m = hist[in[i]-'A']; // } // } // } // for (int i=m; i>0; i--) { // int white = 0; // for (int j=0; j<26; j++) { // if (hist[j] < i) white++; // else { // for (int k=0; k<white; k++) { // if (!(white - j == 0 && k == 0)) cout << ' '; // cout << ' '; // } // if (j) cout << " *"; // else cout << '*'; // white = 0; // } // } // cout << endl; // } // for (int i=0; i<25; i++) { // char ab = i + 'A'; // cout << ab << " "; // } // cout << "Z" << endl; // } #include<iostream> #include<string> #include<algorithm> using namespace std; #define REP(i,b,n) for(int i=b;i<n;i++) #define rep(i,n) REP(i,0,n) #define ALL(C) (C).begin(),(C).end() void solve(string &in){ int cnt[26]={0}; int rmax=0; rep(i,in.size())if (isupper(in[i]))cnt[in[i]-'A']++; rep(i,26)rmax=max(rmax,cnt[i]); for(int i=rmax;i>0;i--){ int whitenum = 0; rep(j,26){ if (cnt[j] < i)whitenum++; else { rep(k,whitenum){ if (!(whitenum - j ==0 && k == 0))cout << ' '; cout << ' '; } if (j)cout << " *"; else cout << '*'; whitenum = 0; } } cout << endl; } rep(i,26){ if (i)cout << ' '; cout << (char)('A' + i); } cout << endl; } main(){ string in,tmp; while(getline(cin,tmp))in+=tmp; solve(in); }
3062
問題じゃない
#include <iostream> using namespace std; int main() { string in; while (getline(cin, in)) cout << in << endl; }