よじろめ覚書

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

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

ABC046B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer

ABC

問題:B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer #include <cmath> #include <iostream> using namespace std; int main(void) { int n, k; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> k; cout << k * (int)pow((k - 1), (n - 1)) << "\n";</iostream></cmath>…

ABC046A - AtCoDeerくんとペンキ / AtCoDeer and Paint Cans

ABC

問題:A - AtCoDeerくんとペンキ / AtCoDeer and Paint Cans #include <iostream> #include <set> using namespace std; int main(void) { int a, b, c; set<int> se; cin.tie(0); ios::sync_with_stdio(false); cin >> a; cin >> b; cin >> c; se.insert(a); se.insert(b); se.i</int></set></iostream>…

ABC045B - 3人でカードゲームイージー / Card Game for Three (ABC Edit)

ABC

問題:B - 3人でカードゲームイージー / Card Game for Three (ABC Edit) #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s_a, s_b, s_c; char card, flg = 'Z'; int length = 0; cin.</string></iostream>…

ABC045A - 台形 / Trapezoids

ABC

問題:A - 台形 / Trapezoids #include <iostream> using namespace std; int main(void) { int a, b, h; cin.tie(0); ios::sync_with_stdio(false); cin >> a; cin >> b; cin >> h; cout << (a + b) * h / 2 << "\n"; return 0; }</iostream>

ABC044B - 美しい文字列 / Beautiful Strings

ABC

問題:B - 美しい文字列 / Beautiful Strings #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[26] = {0}; bool flg = true; cin.tie(0); ios::sync_with_stdio(false); cin</string></iostream>…

ABC044A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit)

ABC

問題:A - 高橋君とホテルイージー / Tak and Hotels (ABC Edit) #include <iostream> using namespace std; int main(void){ int n, k, x, y; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cin >> k; cin >> x; cin >> y; cout << (n > k? k * x + (n - k) * </iostream>…

ABC043B - バイナリハックイージー / Unhappy Hacking (ABC Edit)

ABC

問題:B - バイナリハックイージー / Unhappy Hacking (ABC Edit) #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s, ans = ""; cin.tie(0); ios::sync_with_stdio(false); cin >> s; </string></iostream>…

ABC043A - キャンディーとN人の子供イージー / Children and Candies (ABC Edit)

ABC

問題:A - キャンディーとN人の子供イージー / Children and Candies (ABC Edit) #include <iostream> using namespace std; int main(void){ int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << n * (n + 1) / 2 << "\n"; return 0; }</iostream>

ABC042B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)

ABC

問題:B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition) #include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(a) (a).begin(), (a).end() #define PB pu</vector></string></iostream></algorithm>…

ABC042A - 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition)

ABC

問題:A - 和風いろはちゃんイージー / Iroha and Haiku (ABC Edition) #include <iostream> using namespace std; int getFive(int x_num) { return (x_num == 5? 1 : 0); } int getSeven(int x_num) { return (x_num == 7? 1 : 0); } int main(void){ int a, b, c, c</iostream>…

ABC041B - 直方体

ABC

問題:B - 直方体 #include <iostream> using namespace std; int main(void) { const long long MOD = 1e9 + 7; long long a, b, c; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c; cout << ((a * b) % MOD * (c % MOD)) % MOD << "\n"; return 0; }</iostream>

ABC041A - 添字

ABC

問題:A - 添字 #include <iostream> #include <string> using namespace std; int main(void) { string s; int i; cin.tie(0); ios::sync_with_stdio(false); cin >> s; cin >> i; cout << s[i - 1] << "\n"; return 0; }</string></iostream>

ABC040B - □□□□□

ABC

問題:B - □□□□□ #include <algorithm> #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void){ int n, h, w, r, ans; cin.tie(0); ios::sync_with_stdio(false); cin >> n; ans = n; FOR(i, 1, n + 1) { h = i; w = n </iostream></algorithm>…

ABC040A - 赤赤赤赤青

ABC

問題:A - 赤赤赤赤青 #include <algorithm> #include <iostream> using namespace std; int main(void) { int n, x; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> x; cout << min(n - x, x - 1) << "\n"; return 0; }</iostream></algorithm>

ABC039B - エージェント高橋君

ABC

問題:B - エージェント高橋君 #include <cmath> #include <iostream> using namespace std; int main(void) { int x; cin.tie(0); ios::sync_with_stdio(false); cin >> x; cout << round(sqrt(sqrt(x))) << "\n"; return 0; }</iostream></cmath>

ABC039A - 高橋直体

ABC

問題:A - 高橋直体 #include <iostream> using namespace std; int main(void) { int a, b, c; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c; cout << 2 * ((a * b) + (b * c) + (c * a)) << "\n"; return 0; } 直方体の表面積 = 2(ab + bc + ac) a </iostream>…

ABC038A - お茶

ABC

問題:A - お茶 #include <iostream> #include <string> using namespace std; int main(void) { string s; cin.tie(0); ios::sync_with_stdio(false); cin >> s; cout << (s[s.length() - 1] == 'T'? "YES" : "NO") << "\n"; return 0; }</string></iostream>

ABC037B - 編集

ABC

問題:B - 編集 #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) int main(void) { int n, q, l, r, t, a[100] = {0}; cin.tie(0); ios::sync_with_stdio(false); cin</iostream>…

ABC037A - 饅頭

ABC

問題:A - 饅頭 #include <algorithm> #include <iostream> using namespace std; int main(void) { int a, b, c; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c; cout << c / min(a, b) << "\n"; return 0; }</iostream></algorithm>

ABC036B - 回転

ABC

問題:B - 回転 #include <iostream> #include <string> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void){ int n; string s[50]; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin >> s[i]; } REP(i, n) </vector></string></iostream>…

ABC036A - お茶

ABC

問題:A - お茶 #include <iostream> using namespace std; int main(void) { int a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; cout << (b % a? b / a + 1 : b / a) << "\n"; return 0; }</iostream>

ABC035B - ドローン

ABC

問題:B - ドローン #include <algorithm> #include <cstdlib> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s; int t, x = 0, y = 0, cnt = 0, ans; cin.tie(0); ios::sync_with_stdio(false); cin >> s</string></iostream></cstdlib></algorithm>…

ABC035A - テレビ

ABC

問題: A - テレビ #include <iostream> using namespace std; int main(void) { int w, h; cin.tie(0); ios::sync_with_stdio(false); cin >> w >> h; cout << (w * 3 == h * 4? "4:3" : "16:9") << "\n"; return 0; } 4と3で割り切れたら、4:3と表示するようにしてい</iostream>…

ABC034B - ペア

ABC

問題:B - ペア #include <iostream> using namespace std; int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << (n % 2? n + 1 : n - 1) << "\n"; return 0; }</iostream>

ABC034A - テスト

ABC

問題:A - テスト #include <iostream> using namespace std; int main(void) { int x, y; cin.tie(0); ios::sync_with_stdio(false); cin >> x >> y; cout << (x < y? "Better" : "Worse") << "\n"; return 0; } scanfの戻り値とかの考慮が嫌なので、これからはcin, c</iostream>…

ABC033B - 町の合併

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) { int n, p, sum = 0, max = 0; string s, ans; cin >> n; REP(i, n) { cin >> s >> p; sum += p; if (max < p) {</string></iostream></cstdio>…

ABC033A - 暗証番号

ABC

問題:A - 暗証番号 #include <cstdio> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string n; bool flg = false; cin >> n; REP(i, n.length() - 1) { if (n[i] != n[i + 1]) { flg = true; } } i</string></iostream></cstdio>…

ABC032B - 高橋君とパスワード

ABC

問題:B - 高橋君とパスワード #include <cstdio> #include <iostream> #include <string> #include <set> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s; int k; set<string> se; cin >> s; scanf ("%d", &k); REP(i, s.length()) { if (i + k </string></set></string></iostream></cstdio>…

ABC032A - 高橋君と青木君の好きな数

ABC

問題:A - 高橋君と青木君の好きな数 #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) int gcd(int a, int b) { return (a % b == 0? b : gcd(b, a % b)); } int lcm(int a, int b) { return a * b / gcd(a, b); } i</iostream>…

ABC031B - 運動管理

ABC

問題:B - 運動管理 #include <algorithm> #include <cstdio> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int l, h, n, a; scanf ("%d %d", &l, &h); scanf ("%d", &n); REP(i, n) { scanf ("%d", &a); if (a < l) { pr</iostream></cstdio></algorithm>…