よじろめ覚書

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

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

ABC107A - Train

ABC

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

ABC106B - 105

ABC

問題:B - 105 #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) bool getJudge(int x_n) { int cnt = 0; FOR(i, 1, x_n + 1) { if (x_n % i == 0) { cnt++; } } return cnt == 8; } int main(void) { int n, ans = 0;</iostream>…

ABC106A - Garden

ABC

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

ABC105B - Cakes and Donuts

ABC

問題:B - Cakes and Donuts #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n; bool flg = false; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n / 4 + 1) { REP(j, n / 7 + 1) { </iostream>…

ABC105A - AtCoder Crackers

ABC

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

ABC104B - AcCepted

ABC

問題:B - AcCepted #include <iostream> #include <string> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) bool getJudge(string s) { int cnt = 0; if (s[0] != 'A') { return false; } FOR(i, 1, s.length()) { if (s[i] == 'C' && (i < 2 ||</string></iostream>…

ABC104A - Rated for Me

ABC

問題:A - Rated for Me #include <iostream> #include <string> using namespace std; int getRatedContest(int x_r) { if (x_r < 1200) { return 0; } else if (x_r < 2800) { return 1; } else { return 2; } } int main(void) { int r; const string contest[3] = {"ABC", </string></iostream>…

ABC103B - String Rotation

ABC

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

ABC103A - Task Scheduling Problem

ABC

問題:A - Task Scheduling Problem #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { const int INF = 1 << 30; int a, max_a = INF * (-1), min_a = INF; REP(i, 3) { cin >> a; max_a = max(</iostream></algorithm>…

ABC102B - Maximum Difference

ABC

問題:B - Maximum Difference #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { const int INF = 1 << 30; int n, a[100], max_a = INF * (-1), min_a = INF; cin.tie(0); ios::sync_with_stdi</iostream></algorithm>…

ABC102A - Multiple of 2 and N

ABC

問題:A - Multiple of 2 and N #include <iostream> using namespace std; int GCD(int a, int b){ return b? GCD(b, a % b) : a; } int LCM(int a, int b) { return a * b / GCD(a, b); } int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> </iostream>…

ABC101B - Digit Sums

ABC

問題:B - Digit Sums #include <iostream> using namespace std; int getS(int x_n) { int ret = 0; while (x_n > 0) { ret += x_n % 10; x_n /= 10; } return ret; } int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; cout << (n % getS</iostream>…

ABC101A - Eating Symbols Easy

ABC

問題:A - Eating Symbols Easy #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int getCount(string x_s, char x_op) { int cnt = 0; REP(i, x_s.length()) { if (x_s[i] == x_op) { ++cnt; } } return cnt; }</string></iostream>…

ABC100B - Ringo's Favorite Numbers

ABC

問題:B - Ringo's Favorite Numbers #include <cmath> #include <iostream> using namespace std; #define DIGIT 100 int getDivCount(int x_val) { int cnt = 0; while (x_val % 100 == 0) { x_val /= 100; ++cnt; } return cnt; } int main(void) { int d, n, num, val; ci</iostream></cmath>…

ABC100A - Happy Birthday!

ABC

問題:A - Happy Birthday! #include <iostream> using namespace std; int main(void) { int a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b; cout << (a <= 8 && b <= 8? "Yay!" : ":(") << "\n"; return 0; } "\n;で提出し、1CE。。</iostream>

ABC099B - Stone Monument

ABC

問題:B - Stone Monument #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) / 2 - b << "\n"; return 0; }</iostream>

ABC099 - ABD

ABC

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

ABC098B - Cut and Count

ABC

問題:B - Cut and Count #include <iostream> #include <string> 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) bool isMatch(string str, int s, int g, char c) { FOR(i, s, g) { if (str[i]</string></iostream>…

ABC098A - Add Sub Mul

ABC

問題:A - Add Sub Mul #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>

ABC097B - Exponential

ABC

問題:B - Exponential #include <algorithm> #include <cmath> #include <iostream> using namespace std; int main(void){ int x, ans = 1; cin.tie(0); ios::sync_with_stdio(false); cin >> x; for (int b = 2; b <= x; ++b) { for (int p = 2; (int)pow((double)b, (double)p) <= x;</iostream></cmath></algorithm>…

ABC097A - Colorful Transceivers

ABC

問題:A - Colorful Transceivers #include <cstdlib> #include <iostream> using namespace std; int main(void) { int a, b, c, d; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c >> d; if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) { cout </iostream></cstdlib>…

ABC096B - Maximum Sum

ABC

問題:B - Maximum Sum #include <algorithm> #include <cmath> #include <iostream> using namespace std; int main(void) { int a, b, c, k; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> c; cin >> k; cout << a + b + c + max(a, max(b, c)) * ((int)pow(2.0, k) - 1) </iostream></cmath></algorithm>…

ABC096A - Day of Takahashi

ABC

問題:A - Day of Takahashi #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? a : a - 1) << "\n"; return 0; }</iostream>

ABC095B - Bitter Alchemy

ABC

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

ABC095A - Something on It

ABC

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

ABC094B - Toll Gates

ABC

問題:B - Toll Gates #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, m, x, a, left = 0, right = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m >> x; REP(i, m) { ci</iostream></algorithm>…

ABC094A - Cats and Dogs

ABC

問題:A - Cats and Dogs #include <iostream> using namespace std; int main(void) { int a, b, x; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> x; cout << (a <= x && x <= a + b? "YES" : "NO") << "\n"; return 0; }</iostream>

ABC093B - Small and Large Integers

ABC

問題:B - Small and Large Integers #include <algorithm> #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { int a, b, k; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> k; FOR(i, a, min(b, a </iostream></algorithm>…

ABC093A - abc of ABC

ABC

問題:A - abc of ABC #include <iostream> #include <string> using namespace std; int main(void) { string s; cin.tie(0); ios::sync_with_stdio(false); cin >> s; cout << (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]? "Yes" : "No") << "\n"; return 0; }</string></iostream>