2020-01-19から1日間の記事一覧
問題: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>
問題: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>…
問題: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>
問題: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>…
問題: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>
問題: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>
問題: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>
問題: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>…
問題: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>
問題: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>…
問題: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>…
問題: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>…
問題: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>…