よじろめ覚書

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

ABC

ABC139B - Power Socket

ABC

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

ABC139A - Tenki

ABC

問題:A - Tenki #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, t; cin.tie(0); ios::sync_with_stdio(false); cin >> s; cin >> t; REP(i, s.length()) { if (s[i] </string></iostream>…

ABC138B - Resistors in Parallel

ABC

問題:B - Resistors in Parallel #include <iomanip> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, a; double ans = 0.0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin >> a; </iostream></iomanip>…

ABC138A - Red or Not

ABC

問題: #include <iostream> #include <string> using namespace std; int main(void) { int a; string s; cin.tie(0); ios::sync_with_stdio(false); cin >> a; cin >> s; cout << (a < 3200? "red" : s) << "\n"; return 0; }</string></iostream>

ABC137B - One Clue

ABC

問題:B - One Clue #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { int k, x; cin.tie(0); ios::sync_with_stdio(false); cin >> k >> x; FOR (i, x - k + 1, x + k) { cout << i; cout << (i != </iostream>…

ABC137A - +-x

ABC

問題:A - +-x #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(a + b, max(a - b, a * b)) << "\n"; return 0; }</iostream></algorithm>

ABC136B - Uneven Numbers

ABC

問題:B - Uneven Numbers #include <iostream> #include <string> 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; REP(i, n) { if (to_string(i + 1).length()</string></iostream>…

ABC136A - Transfer

ABC

問題:A - Transfer #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 << max(0, c - (a - b)) << "\n"; return 0; }</iostream></algorithm>

ABC135B - 0 or 1 Swap

ABC

問題:B - 0 or 1 Swap #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, cnt = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; vector<int> p(n); REP(i, n) { cin >> p[i]; if (p[</int></vector></iostream>…

ABC135A - Harmony

ABC

問題:A - Harmony #include <iostream> using namespace std; int main(void) { int a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; if (a % 2 != b % 2) { cout << "IMPOSSIBLE" << "\n"; } else { cout << (a + b) / 2 << "\n"; } return 0; }</iostream>

ABC134B - Golden Apple

ABC

問題:B - Golden Apple #include <iostream> using namespace std; int main(void) { int n, d; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> d; cout << (n + 2 * d) / (2 * d + 1); return 0; }</iostream>

ABC134A - Dodecagon

ABC

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

ABC133B - Good Distance

ABC

問題:B - Good Distance #include <cstdlib> #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, d; cin.tie(0); ios::sync_with_stdio(fal</vector></iostream></cstdlib>…

ABC133A - T or T

ABC

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

ABC132B - Ordinary Number

ABC

問題:B - Ordinary Number #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> p(n); REP(i, n) { cin >> p[i]; } </int></vector></iostream>…

ABC132A - Fifty-Fifty

ABC

問題:A - Fifty-Fifty #include <algorithm> #include <iostream> #include <string> using namespace std; #define ALL(c) (c).begin(), (c).end() int main(void) { string s; cin.tie(0); ios::sync_with_stdio(false); cin >> s; sort(ALL(s)); cout << (s[0] == s[1] && s[1] != s[2</string></iostream></algorithm>…

ABC131B - Bite Eating

ABC

問題:B - Bite Eating #include <iostream> using namespace std; int main(void) { int n, l, left, right, eat; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> l; left = l; right = l + n - 1; if (right <= 0) { eat = right; } else if (left >= 0) { e</iostream>…

ABC131A - Security

ABC

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

ABC130B - Bounding

ABC

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

ABC130A - Rounding

ABC

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

ABC129B - Balance

ABC

問題:B - Balance #include <algorithm> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { const int INF = 1 << 30; int n, ans = INF, sum = 0, part_sum = 0; cin.tie(0); ios::sync_with_stdio(false)</vector></iostream></algorithm>…

ABC129A - Airplane

ABC

問題:A - Airplane #include <algorithm> #include <iostream> using namespace std; int main(void) { int p, q, r; cin.tie(0); ios::sync_with_stdio(false); cin >> p >> q >> r; cout << p + q + r - max(p, max(q, r)) << "\n"; return 0; }</iostream></algorithm>

ABC128B - Guidebook

ABC

問題:B - Guidebook #include <algorithm> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; typedef pair<string, int> PSI; #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(c) (c).begin(), (c).end() #define MP make_pair #define fst first #defi</string,></vector></utility></string></iostream></algorithm>…

ABC128A - Apple Pie

ABC

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

ABC127B - Algae

ABC

問題:B - Algae #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int r, d; vector<int> x(11); cin.tie(0); ios::sync_with_stdio(false); cin >> r >> d >> x[0]; REP(i, 10) { x[i + 1] = r * x</int></vector></iostream>…

ABC127A - Ferris Wheel

ABC

問題:A - Ferris Wheel #include <iostream> using namespace std; int main(void) { int a, b, ans; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; if (a >= 13) { ans = b; } else if (a >= 6) { ans = b / 2; } else { ans = 0; } cout << ans << "\n"</iostream>…

ABC126B - YYMM or MMYY

ABC

問題:B - YYMM or MMYY #include <iostream> #include <string> #include <stdexcept> using namespace std; int checkYearMonth(string x_s) { int num = stoi(x_s); if (1 <= num % 100 && num % 100 <= 12 && 1 <= num / 100 && num / 100 <= 12) { return 0; } else if (1 <= num % 1</stdexcept></string></iostream>…

ABC126A - Changing a Character

ABC

問題:A - Changing a Character #include <cctype> #include <iostream> #include <string> using namespace std; int main(void) { int n, k; string s; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> k; cin >> s; s[k - 1] = tolower(s[k - 1]); cout << s << "\n"; retur</string></iostream></cctype>…

ABC125B - Resale

ABC

問題:B - Resale #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> v(n), c(n); REP(i, n) { cin >> v[i]; } REP</int></vector></iostream>…

ABC125A - Biscuit Generator

ABC

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