よじろめ覚書

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

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

ABC092B - Chocolate

ABC

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

ABC092A - Traveling Budget

ABC

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

ABC091B - Two Colors Card Game

ABC

問題:B - Two Colors Card Game #include <algorithm> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, m, ans = 0, score = 0; string s[100], t[100]; cin.tie(0); ios::sync_with_stdio(false)</string></iostream></algorithm>…

ABC091A - Two Coins

ABC

問題:A - Two Coins #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 << ((a + b) >= c? "Yes" : "No") << "\n"; return 0; }</iostream>

ABC090B - Palindromic Numbers

ABC

問題:B - Palindromic Numbers #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { int a, b, ans = 0; cin >> a >> b; FOR(i, a, b + 1) { if ((i / 10000) % 10 == i % 10 && (i / 1000) % 10 == (i</iostream>…

ABC090A - Diagonal String

ABC

問題:A - Diagonal String #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { string c, ans = ""; cin.tie(0); ios::sync_with_stdio(false); REP(i, 3) { cin >> c; ans += c[i]; } cout << ans << "\n"</iostream>…

ABC089B - Hina Arare

ABC

問題:B - Hina Arare #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n; char s; bool four_flg = false; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin >> s; if (s == 'Y</iostream>…

ABC089A - Grouping 2

ABC

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

ABC088B - Card Game for Two

ABC

問題:B - Card Game for Two #include <algorithm> #include <functional> #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, ans = 0; vector<int>vec; cin.tie(0); ios::sync_with_stdio(f</int></vector></iostream></functional></algorithm>…

ABC088A - Infinite Coins

ABC

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

ABC087B - Coins

ABC

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

ABC087A - Buying Sweets

ABC

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

ABC086B - 1 21

ABC

問題:B - 1 21 #include <cmath> #include <iostream> #include <string> using namespace std; int main(void) { string a, b; int n; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; n = stoi(a + b); cout << (n == (int)sqrt((double)n) * (int)sqrt((double)n)? "Yes</string></iostream></cmath>…

ABC086A - Product

ABC

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

ABC085B - Kagami Mochi

ABC

問題:B - Kagami Mochi #include <iostream> #include <set> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, d; set<int> se; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin >> d; se.insert(d); } cou</int></set></iostream>…

ABC085A - Already 2018

ABC

問題:A - Already 2018 #include <iostream> #include <string> using namespace std; int main(void) { string s; cin.tie(0); ios::sync_with_stdio(false); cin >> s; s[3] = '8'; cout << s << "\n"; return 0; }</string></iostream>

ABC084B - Postal Code

ABC

問題:B - Postal Code #include <iostream> #include <string> 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 a, b; string s; bool flg = true; cin.tie(0); ios::sync</string></iostream>…

ABC084A - New Year

ABC

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

ABC083B - Some Sums

ABC

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

ABC083A - Libra

ABC

問題:A - Libra #include <iostream> using namespace std; int main(void) { int a, b, c, d; string ret = ""; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c >> d; if (a + b > c + d) { ret = "Left"; } else if (a + b < c + d) { ret = "Right"</iostream>…

ABC082B - Two Anagrams

ABC

問題:B - Two Anagrams #include <algorithm> #include <iostream> #include <string> using namespace std; int main(void) { string s, t; cin.tie(0); ios::sync_with_stdio(false); cin >> s; cin >> t; sort (s.begin(), s.end()); sort (t.begin(), t.end()); reverse (t.begin(), </string></iostream></algorithm>…

ABC082A - Round Up the Mean

ABC

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

ABC081B - Shift only

ABC

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

ABC081A - Placing Marbles

ABC

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

ABC080B - Harshad Number

ABC

問題:B - Harshad Number #include <iostream> using namespace std; int main(void) { int n, copy_n, sum = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; copy_n = n; while (copy_n >= 1) { sum += copy_n % 10; copy_n /= 10; } cout << (n % sum == 0</iostream>…

ABC080A - Parking

ABC

問題:A - Parking #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>

ABC079B - Lucas Number

ABC

問題:B - Lucas Number #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { int n; long long l[100]; cin.tie(0); ios::sync_with_stdio(false); cin >> n; l[0] = 2; l[1] = 1; FOR(i, 2, n + 1) { </iostream>…

ABC079A - Good Integer

ABC

問題:A - Good Integer #include <iostream> #include <string> using namespace std; int main(void) { string n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) { cout << "Yes" << "\n"; } </string></iostream>…

ABC078B - ISU

ABC

問題:B - ISU #include <iostream> using namespace std; int main(void) { int x, y, z, cnt = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> x >> y >> z; while (true) { int width = y * cnt + z * (cnt + 1); if (x < width) { cnt--; break; } cnt++; } </iostream>…

ABC078A - HEX

ABC

問題:A - HEX #include <iostream> using namespace std; int main(void) { char x, y; cin.tie(0); ios::sync_with_stdio(false); cin >> x >> y; if (x - 'A' < y - 'A') { cout << "<\n"; } else if (x - 'A' > y - 'A') { cout << ">\n"; } else { cout << "=\n";</iostream>…