とりあえずAOJ
今日は技術の時間とかえってからでとりあえずAOJ。
解けたやつだけ。
0029
AOJ_botに勧められたよ♪
C++のコード短さ3位だったよ♪
#include <iostream> #include <map> using namespace std; int main() { string str; map<string, int> m; string pop_s, len_s; int pop=0, len=0; while (cin >> str) { m[str]++; if (m[str]>pop) { pop = m[str]; pop_s = str; } if (str.length()>len) { len = str.length(); len_s = str; } } cout << pop_s << " " << len_s << endl; }
0049
入力はカンニングしました。
#include <cstdio> #include <algorithm> #include <string> using namespace std; int main() { int A=0,B=0,C=0,D=0; char bl[3]; while (scanf("%*d,%2s",bl)!=EOF) { if (string(bl)=="A") { A++; } else if (string(bl)=="B") { B++; } else if (string(bl)=="AB") { C++; } else if (string(bl)=="O") { D++; } } printf("%d\n%d\n%d\n%d\n",A,B,C,D); }
0051
なんだこの問題。
#include <iostream> #include <sstream> #include <algorithm> #include <string> using namespace std; int main() { int n; cin >> n; for (int ix=0;ix<n;ix++) { string num; cin >> num; sort(num.begin(),num.end()); stringstream os; os.str(num); int min; os >> min; reverse(num.begin(),num.end()); stringstream oss; oss.str(num); int max; oss >> max; cout << max-min << endl; } }
精進、精進。