ショートヘアセット / paizaOnlineHackathon8
#include <iostream> #include <string> using namespace std; void Solve(int n) { string s; cin >> s; for (int i=0; i<n; ++i) cout << s << endl; } int main(void) { int n; cin >> n; Solve(n); return 0; }
与えられた文字列sをn回出力する。
〜了〜
松江Ruby会議ミッション / paizaOnlineHackathon6+
#include <algorithm> #include <iostream> #include <map> #include <string> using namespace std; void Solve(int n) { map<string,int> w, left, center; string word, str, leftWord = "", centerWord = "", rightWord = ""; w.clear(); left.clear(); center.clear(); for (int i=0; i<n; ++i) { cin >> word; if ( w.find(word) == w.end() ) w[word] = 1; else ++w[word]; } for (map<string,int>::iterator it=w.begin(); it!=w.end(); ++it) { str = it->first; reverse( str.begin(),str.end() ); if (it->first == str) center[str] = it->second; else if ( w.find(str) != w.end() ) left[min(it->first,str)] = min(it->second,w[str]); } for (map<string,int>::iterator it=center.begin(); it!=center.end(); ++it) if (it->second >= 2) { left[it->first] = it->second/2; it->second %= 2; } for (map<string,int>::iterator it=left.begin(); it!=left.end(); ++it) for (int i=0; i<it->second; ++i) leftWord += it->first; for (map<string,int>::iterator it=center.begin(); it!=center.end(); ++it) if (it->second == 1) centerWord += it->first; rightWord = leftWord; reverse( rightWord.begin(),rightWord.end() ); cout << leftWord + centerWord + rightWord << endl; } int main(void) { int n; cin >> n; Solve(n); return 0; }
左側と真ん中に分けて登録し右側は左側を逆順にしたものを用い出力。
〜了〜
六村リオミッション / paizaOnlineHackathon6
#include <iostream> using namespace std; void Solve(int n) { int t, s; double x = 0.0, y = 0.0, xx, yy; for (int i=0; i<n; ++i) { cin >> t >> s; if (t == 1) x += s; else if (t == 2) y += s; else { xx = x; yy = y; x -= s*x/(xx+yy); y -= s*y/(xx+yy); } } cout << (int)( 100*y/(x+y) ) << endl; } int main(void) { int n; cin >> n; Solve(n); return 0; }
1なら湯を加算、2ならコーヒーを加算、3なら両方を減算。
最後に濃度を出力。
〜了〜
緑川つばめミッション / paizaOnlineHackathon6
#include <iostream> using namespace std; void Solve(int n) { cout << n+(n/10)+(n%10) << endl; } int main(void) { int n; cin >> n; Solve(n); return 0; }
入力した値と入力した値の桁を分けて足し算した結果を出力。
〜了〜
霧島京子ミッション / paizaOnlineHackathon6
#include <iostream> using namespace std; void Solve(int n) { int t[100+1], m, d; for (int i=0; i<n; ++i) cin >> t[i]; cin >> m; for (int i=0; i<m; ++i) { cin >> d; bool flg[100+1] = {false}; while (d != n-1) { if (d<=0 || n-1<d || flg[d]) break; flg[d] = true; d += t[d]; } cout << (d==n-1? "Yes" : "No") << endl; } } int main(void) { int n; cin >> n; Solve(n); return 0; }
範囲外と既通過を気をつける。ゴールに辿り着けた場合Yes、そうでない場合Noを出力。
〜了〜
水着 / paizaOnlineHackathon7
#include <iostream> using namespace std; #define MOD 1000000000 void Solve(int n) { long long answer = 1; for (int i=n; i>0; --i) { answer *= i; while (answer%10 == 0) answer /= 10; if (answer > MOD) answer %= MOD*(long long)10; } cout << answer%MOD << endl; } int main(void) { int n; cin >> n; Solve(n); return 0; }
後ろから階乗を求め、後ろの0を削除と前の0を削除して結果を出力。
〜了〜
サンタ服 / paizaOnlineHackathon7
#include <algorithm> #include <iostream> using namespace std; void Solve(int x, int y,int z, int n) { int d, a, x_data[100+1], y_data[100+1], j = 2, k = 2, min_x = 100, min_y = 100; x_data[0] = 0; y_data[0] = 0; x_data[1] = x; y_data[1] = y; for (int i=1; i<=n; ++i) { cin >> d >> a; (d == 0)? x_data[j++] = a : y_data[k++] = a; } sort(x_data, x_data+j); sort(y_data, y_data+k); for (int i=1; i<j; ++i) min_x = min(min_x, x_data[i]-x_data[i-1]); for (int i=1; i<k; ++i) min_y = min(min_y, y_data[i]-y_data[i-1]); cout << min_x * min_y * z << endl; } int main(void) { int x, y, z, n; cin >> x >> y >> z >> n; Solve(x,y,z,n); return 0; }
高さは変わらないので縦・横の最小値を取り、体積を求め出力。
〜了〜