よじろめ覚書

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

ABC154B - I miss you...

ABC

問題:B - I miss you... #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string s; cin.tie(0); ios::sync_with_stdio(false); cin >> s; REP(i, s.length()) { cout << "x"; if (i == s.len</string></iostream>…

ABC154A - Remaining Balls

ABC

問題:A - Remaining Balls #include <iostream> #include <string> using namespace std; int main(void) { string s, t, u; int a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> s >> t; cin >> a >> b; cin >> u; if (s == u) { --a; } else { --b; } cout << a << </string></iostream>…

ABC153B - Common Raccoon vs Monster

ABC

問題:B - Common Raccoon vs Monster #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int h, n, a; cin.tie(0); ios::sync_with_stdio(false); cin >> h >> n; REP(i, n) { cin >> a; h -= a; } cout <</iostream>…

ABC153A - Serval vs Monster

ABC

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

ABC152B - Comparing Strings

ABC

問題:B - Comparing Strings #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { char a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; REP(i, max(a - '0', b - '0')) { cout <</iostream></algorithm>…

ABC152A - AC or WA

ABC

問題:A - AC or WA #include <iostream> using namespace std; int main(void) { int n, m; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; cout << (n == m? "Yes" : "No") << "\n"; return 0; }</iostream>

ABC151B - Achieve the Goal

ABC

問題:B - Achieve the Goal #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, k, m, a, sum = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> k >> m; REP(i, n - 1) { cin >> a; sum </iostream>…

ABC151A - Next Alphabet

ABC

問題:A - Next Alphabet #include <iostream> using namespace std; int main(void) { char c; cin.tie(0); ios::sync_with_stdio(false); cin >> c; cout << (char)(c + 1) << "\n"; return 0; }</iostream>

ABC150B - Count ABC

ABC

問題:B - Count ABC #include <iostream> #include <string> using namespace std; int main(void) { int n, pos = 0, ans = 0; string s; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cin >> s; while (s.find("ABC", pos) != string::npos) { ans++; pos = s.find(</string></iostream>…

ABC150A - 500 Yen Coins

ABC

問題:A - 500 Yen Coins #include <iostream> using namespace std; int main(void) { int k, x; cin.tie(0); ios::sync_with_stdio(false); cin >> k >> x; cout << (x <= k * 500? "Yes" : "No") << "\n"; return 0; }</iostream>

ABC149B - Greedy Takahashi

ABC

問題:B - Greedy Takahashi #include <iostream> using namespace std; int main(void) { long long a, b, k; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> k; a -= k; if (a < 0) { b += a; if (b < 0) { b = 0; } a = 0; } cout << a << " " << b <<</iostream>…

ABC149A - Strings

ABC

問題:A - Strings #include <iostream> #include <string> using namespace std; int main(void) { string s, t; cin.tie(0); ios::sync_with_stdio(false); cin >> s >> t; cout << t + s << "\n"; return 0; }</string></iostream>

ABC148B - Strings with the Same Length

ABC

問題:B - Strings with the Same Length #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n; string s, t; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cin >> s >> t; REP(i, n</string></iostream>…

ABC148A - Round One

ABC

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

ABC147B - Palindrome-philia

ABC

問題:B - Palindrome-philia #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; cin.tie(0); ios::sync_with_stdio(false); cin >> s; REP(i, s.length() / 2) { if (i </string></iostream>…

ABC147A - Blackjack

ABC

問題:A - Blackjack #include <iostream> using namespace std; int main(void) { int a1, a2, a3; cin.tie(0); ios::sync_with_stdio(false); cin >> a1 >> a2 >> a3; cout << (a1 + a2 + a3 <= 21? "win" : "bust") << "\n"; return 0; }</iostream>

ABC146B - ROT N

ABC

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

ABC146A - Can't Wait for Holiday

ABC

問題:A - Can't Wait for Holiday #include <algorithm> #include <iostream> #include <iterator> #include <string> #include <vector> using namespace std; #define ALL(c) (c).begin(), (c).end() int main(void) { const vector<string> WEEKDAY = {"SUN", "MON", "TUE", "WED" , "THU", "FRI", "SAT"}; strin</string></vector></string></iterator></iostream></algorithm>…

ABC145B - Echo

ABC

問題:B - Echo #include <iostream> #include <string> using namespace std; int main(void) { int n; string s; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cin >> s; cout << (n % 2 == 0 && s.substr(0, n / 2) == s.substr(n / 2, n)? "Yes" : "No") << "\n"; </string></iostream>…

ABC145A - Circle

ABC

問題:A - Circle #include <iostream> using namespace std; int main(void) { int r; cin.tie(0); ios::sync_with_stdio(false); cin >> r; cout << r * r << "\n"; return 0; }</iostream>

ABC144B - 81

ABC

問題:B - 81 #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { int n; bool flg = false; cin.tie(0); ios::sync_with_stdio(false); cin >> n; FOR(i, 1, 9 + 1) { FOR(j, 1, 9 + 1) { if (i * j =</iostream>…

ABC144A - 9x9

ABC

問題:A - 9x9 #include <iostream> using namespace std; int main(void) { int a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; if (9 < a || 9 < b) { cout << -1 << "\n"; } else { cout << a * b << "\n"; } return 0; }</iostream>

ABC143B - TAKOYAKI FESTIVAL 2019

ABC

問題:B - TAKOYAKI FESTIVAL 2019 #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { int n, sum = 0; cin.tie(0); ios::sync_with_stdi</vector></iostream>…

ABC143A - Curtain

ABC

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

ABC142B - Roller Coaster

ABC

問題:B - Roller Coaster #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, k, h, ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> k; REP(i, n) { cin >> h; if (k <= h) { ans+</iostream>…

ABC142A - Odds of Oddness

ABC

問題:A - Odds of Oddness #include <iomanip> #include <iostream> using namespace std; int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << fixed << setprecision(10) << (n % 2 == 0? n / 2 / (double) n : (n + 1) / 2 / (double) n) <</iostream></iomanip>…

ABC141B - Tap Dance

ABC

問題:B - Tap Dance #include <algorithm> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { const string odd = "RUD", even = "LUD"; string s; bool flg = true; cin.tie(0); ios::sync_with_stdio(fal</string></iostream></algorithm>…

ABC141A - Weather Prediction

ABC

問題:A - Weather Prediction #include <algorithm> #include <iostream> #include <iterator> #include <string> #include <vector> using namespace std; #define ALL(c) (c).begin(), (c).end() int main(void) { vector<string> weather = {"Sunny", "Cloudy", "Rainy"}; string s; cin.tie(0); ios::sync_with_</string></vector></string></iterator></iostream></algorithm>…

ABC140B - Buffet

ABC

問題:B - Buffet #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; vector<int> a(n), b(n), c(n); REP(i, n) { cin >> a[i];</int></vector></iostream>…

ABC140A - Password

ABC

問題:A - Password #include <iostream> using namespace std; int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << n * n * n << "\n"; return 0; }</iostream>