よじろめ覚書

私の理解度重視のソースコードです。

2019-06-01から1ヶ月間の記事一覧

ABC031A - ゲーム

ABC

問題:A - ゲーム #include <algorithm> #include <cstdio> #include <iostream> using namespace std; int main(void) { int a, d; scanf ("%d %d", &a, &d); printf ("%d\n", (min(a, d) + 1) * max(a, d)); return 0; }</iostream></cstdio></algorithm>

ABC030B - 時計盤

ABC

問題:B - 時計盤 #include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; int main(void) { int n, m; double hour, minute, ans; scanf ("%d %d", &n, &m); hour = n % 12 * 30 + m * 0.5; minute = m * 6; ans = min(360 - abs(hour - minute), a</iostream></cstdio></cmath></algorithm>…

ABC030A - 勝率計算

ABC

問題:A - 勝率計算 #include <cstdio> #include <iostream> using namespace std; int main(void) { int a, b, c, d; scanf ("%d %d %d %d", &a, &b, &c, &d); if (b * c > d * a) { printf ("TAKAHASHI\n"); } else if (b * c < d * a) { printf ("AOKI\n"); } else { printf</iostream></cstdio>…

ABC029B - カキ

ABC

#include <cstdio> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int ans = 0; string s; REP(i, 12) { cin >> s; if (s.find('r') != string::npos) { ans++; } } printf ("%d\n", ans); return 0;</string></iostream></cstdio>…

ABC029A - 複数形

ABC

問題:A - 複数形 #include <cstdio> #include <iostream> #include <string> using namespace std; int main(void) { string w; cin >> w; cout << w << "s\n"; return 0; }</string></iostream></cstdio>

ABC028B - 文字数カウント

ABC

問題:B - 文字数カウント #include <cstdio> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s; int cnt[6] = {0}; cin >> s; REP(i, s.length()) { cnt[s[i] - 'A']++; } REP(i, 6) { (i != </string></iostream></cstdio>…

ABC028A - テスト評価

ABC

問題:A - テスト評価 #include <cstdio> #include <iostream> using namespace std; int main(void) { int score; scanf ("%d", &score); if (score >= 100) { printf ("Perfect\n"); } else if (score >= 90) { printf ("Great\n"); } else if (score >= 60) { printf ("Good</iostream></cstdio>…

ABC027B - 島と橋

ABC

問題:B - 島と橋 #include <cstdio> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define PB push_back int main(void) { int n, a, sum = 0, cnt = 0, tmp; vector<int> vec; scanf ("%d", &n); REP(i, n) { scanf ("%d</int></vector></iostream></cstdio>…

ABC027A - 長方形

ABC

問題:A - 長方形 #include <cstdio> #include <iostream> using namespace std; int main(void) { int l1, l2, l3, ans; scanf ("%d %d %d", &l1, &l2, &l3); if (l1 == l2) { ans = l3; } else if (l2 == l3) { ans = l1; } else { ans = l2; } printf ("%d\n", ans); return</iostream></cstdio>…

ABC026B - N重丸

ABC

問題:B - N重丸 #include <algorithm> #include <cmath> #include <cstdio> #include <functional> #include <iostream> using namespace std; #define REP(i, n) for(int i = 0; i < (n); ++i) #define MAX (int)1e3 int main(void) { int n; double r[MAX], s = 0.0; scanf ("%d", &n); REP(i, n) { scanf </iostream></functional></cstdio></cmath></algorithm>…

ABC026A - 掛け算の最大値

ABC

問題:A - 掛け算の最大値 #include <cmath> #include <cstdio> #include <iostream> using namespace std; int main(void) { int a; scanf ("%d", &a); printf ("%d\n", (int)pow((double)a / 2.0, 2)); return 0; }</iostream></cstdio></cmath>

ABC025B - 双子とスイカ割り

ABC

問題:B - 双子とスイカ割り #include <cstdio> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int getDis(int a, int b, int d) { if (d < a) { return a; } if (b < d) { return b; } return d; } int getDir(string</string></iostream></cstdio>…

ABC025A - 25個の文字列

ABC

問題:A - 25個の文字列 #include <cstdio> #include <iostream> #include <string> using namespace std; int main(void) { string s; int n; cin >> s; scanf ("%d", &n); cout << s[(n - 1) / 5] << s[(n - 1) % 5] << "\n"; return 0; }</string></iostream></cstdio>

ABC024B - 自動ドア

ABC

問題:B - 自動ドア #include <cstdio> #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for(int i = 0; i < (n); ++i) #define MAX (int)1e5 int main(void) { int n, t, a[MAX], ans = 0; scanf ("%d %d"</iostream></cstdio>…

ABC024A - 動物園

ABC

問題:A - 動物園 #include <cstdio> #include <iostream> using namespace std; int main(void) { int a, b, c, k, s, t; scanf ("%d %d %d %d", &a, &b, &c, &k); scanf ("%d %d", &s, &t); if (s + t >= k) { a -= c; b -= c; } printf ("%d\n", a * s + b * t); return 0; }</iostream></cstdio>

ABC023B - 手芸王

ABC

問題:B - 手芸王 #include <cstdio> #include <iostream> #include <string> using namespace std; int main(void) { int n, ans = -1; string s, str = "b"; scanf ("%d", &n); cin >> s; if (s == str) { ans = 0; } else { int k = 1; while (n >= str.length()) { if (k % 3 == 0)</string></iostream></cstdio>…

ABC023A - 加算王

ABC

問題:A - 加算王 #include <cstdio> #include <iostream> using namespace std; int main(void) { int x; scanf ("%d", &x); printf ("%d\n", (x / 10) + (x % 10)); return 0; }</iostream></cstdio>

ABC022B - Bumble Bee

ABC

問題:B - Bumble Bee #include <cstdio> #include <iostream> #include <set> using namespace std; #define REP(i, n) for(int i = 0; i < (n); ++i) int main(void) { int n, a; set<int> se; scanf ("%d", &n); REP(i, n) { scanf ("%d", &a); se.insert(a); } printf ("%d\n", n - (</int></set></iostream></cstdio>…

ABC022A - Best Body

ABC

問題:A - Best Body #include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, s, t, w, a, ans = 0; scanf ("%d %d %d", &n, &s, &t); scanf ("%d", &w); if (s <= w && w <= t) { ans++; } RE</iostream></cstdio>…

ABC021B - 嘘つきの高橋くん

ABC

問題:B - 嘘つきの高橋くん #include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for(int i = 0; i < (n); ++i) int main(void) { int n, a, b, k, p, cnt[100] = {0}; bool flg = true; scanf ("%d", &n); scanf ("%d %d", &a, &b); cnt[a - 1] =</iostream></cstdio>…

ABC021A - 足し算

ABC

問題:A - 足し算 #include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, cnt = 0; scanf("%d", &n); REP(i, 4) { if (n & 1 << i) { cnt++; } } printf ("%d\n", cnt); REP(i, 4) { if (n & </iostream></cstdio>…

ABC020B - 足し算

ABC

問題:B - 足し算 #include <cstdio> #include <iostream> #include <string> using namespace std; int main(void) { string a, b, ab; cin >> a >> b; ab = a + b; printf ("%d\n", atoi(ab.c_str()) * 2); return 0; }</string></iostream></cstdio>

ABC020A - クイズ

ABC

問題:A - クイズ #include <cstdio> #include <iostream> using namespace std; int main(void) { int q; scanf ("%d", &q); if (q == 1) { printf ("ABC\n"); } else { printf ("chokudai\n"); } return 0; }</iostream></cstdio>

ABC019B - 高橋くんと文字列圧縮

ABC

問題:B - 高橋くんと文字列圧縮 #include <iostream> #include <string> #include <sstream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { string s, ans; int cnt = 1; stringstream ss; cin >> s; FOR(i, 1, s.length()) { if (s[i </sstream></string></iostream>…

ABC019A - 高橋くんと年齢

ABC

問題:A - 高橋くんと年齢 #include <cstdio> #include <iostream> using namespace std; int main(void) { int a, b, c; scanf ("%d %d %d", &a, &b, &c); if (a > b) { swap(a, b); } if (b > c) { swap(b, c); } if (a > b) { swap(a, b); } printf ("%d\n", b); return 0; }</iostream></cstdio>

ABC018B - 文字列の反転

ABC

問題:B - 文字列の反転 #include <algorithm> #include <cstdio> #include <iostream> #include <string> using namespace std; #define REP(i, n) for(int i = 0 ; i < (n); ++i) int main(void) { string s; int n, a, b; cin >> s; scanf ("%d", &n); REP(i, n) { scanf ("%d %d", &a, &b); re</string></iostream></cstdio></algorithm>…

ABC018A - 豆まき

ABC

問題:A - 豆まき #include <cstdio> #include <iostream> using namespace std; int main(void) { int a, b, c, ar = 1, br = 1, cr = 1; scanf ("%d", &a); scanf ("%d", &b); scanf ("%d", &c); if (a < b) { ar++; } else { br++; } if (b < c) { br++; } else { cr++; } i</iostream></cstdio>…

ABC017B - choku語

ABC

問題:B - choku語 #include <iostream> #include <string> using namespace std; #define REP(i, n) for(int i = 0; i < (n); ++i) bool isChoku(string x_s) { REP(i, x_s.length()) { if (x_s[i] == 'o' || x_s[i] == 'k' || x_s[i] == 'u') { continue; } if (i + 1 <= x_s</string></iostream>…

ABC017A - プロコン

ABC

問題:A - プロコン #include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int s, e, ans = 0; REP(i, 3) { scanf ("%d %d", &s, &e); ans += s * e; } printf ("%d\n", ans / 10); return 0; }</iostream></cstdio>

ABC016B - A±B

ABC

問題:B - A±B Problem #include <cstdio> #include <iostream> using namespace std; int main(void) { int a, b, c; scanf ("%d %d %d", &a, &b, &c); if (a + b == c && a - b == c) { printf ("?\n"); } else if (a + b == c) { printf ("+\n"); } else if (a - b == c) { </iostream></cstdio>…