よじろめ覚書

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

2019-01-01から1年間の記事一覧

ABC121B - Can you solve this?

ABC

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

ABC121A - White Cells

ABC

問題:A - White Cells #include <algorithm> #include <iostream> using namespace std; int main(void) { int h, w, selh, selw; cin.tie(0); ios::sync_with_stdio(false); cin >> h >> w; cin >> selh >> selw; cout << (h - selh) * (w - selw) << "\n"; return 0; }</iostream></algorithm>

ABC120B - K-th Common Divisor

ABC

問題:B - K-th Common Divisor #include <algorithm> #include <iostream> using namespace std; int main(void) { int a, b, k, cnt = 0, ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> a >> b >> k; for (int i = min(a, b); i >= 1; --i) { if (a % i == 0 && b </iostream></algorithm>…

ABC120A - Favorite Sound

ABC

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

ABC119B - Digital Gifts

ABC

問題:B - Digital Gifts #include <iomanip> #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) #define RATE 380000.0 int main(void) { int n; double x, ans = 0.0; string u; cin.tie(0); ios::sync_with_stdio(false)</string></iostream></iomanip>…

ABC119A - Still TBD

ABC

問題:A - Still TBD #include <iostream> #include <string> using namespace std; int main(void) { string s; cin.tie(0); ios::sync_with_stdio(false); cin >> s; cout << (s <= "2019/04/30"? "Heisei" : "TBD") << "\n"; return 0; }</string></iostream>

ABC118B - Foods Loved by Everyone

ABC

問題:B - Foods Loved by Everyone #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, m, k, a, ans = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; vector<int> cnt(m, 0); </int></vector></iostream>…

ABC118A - B +/- A

ABC

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

ABC117B - Polygon

ABC

問題:B - Polygon #include <algorithm> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, l, sum_l = 0, max_l = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin >> l; </vector></iostream></algorithm>…

ABC117A - Entrance Examination

ABC

問題:A - Entrance Examination #include <iostream> #include <iomanip> using namespace std; int main(void) { int t, x; cin.tie(0); ios::sync_with_stdio(false); cin >> t >> x; cout << fixed << setprecision(10) << t / (double)x << "\n"; return 0; }</iomanip></iostream>

ABC116B - Collatz Problem

ABC

問題:B - Collatz Problem #include <iostream> #include <set> using namespace std; int getCollatz(int x_num) { return (x_num % 2)? 3 * x_num + 1 : x_num / 2; } int main(void) { int s, cnt = 0; set<int> se_num; cin.tie(0); ios::sync_with_stdio(false); cin >> s;</int></set></iostream>…

ABC116A - Right Triangle

ABC

問題:A - Right Triangle #include <algorithm> #include <iostream> using namespace std; int main(void) { int n[3]; cin.tie(0); ios::sync_with_stdio(false); cin >> n[0] >> n[1] >> n[2]; sort(n, n + 3); cout << (n[0] * n[1]) / 2 << "\n"; return 0; }</iostream></algorithm>

ABC115B - Christmas Eve Eve

ABC

問題:B - Christmas Eve Eve #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int n, p, max_p = 0, sum = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i, n) { cin >> p; ma</iostream></algorithm>…

ABC115A - Christmas Eve Eve Eve

ABC

問題:A - Christmas Eve Eve Eve #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int d; cin.tie(0); ios::sync_with_stdio(false); cin >> d; cout << "Christmas"; REP(i, 25 - d) { cout << " Eve";</iostream>…

ABC114B - 754

ABC

問題:B - 754 #include <algorithm> #include <cstdlib> #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 = 753; cin.tie(0); ios::sync_with_stdio(false); cin >> s; REP(i, s.length() - 2) {</string></iostream></cstdlib></algorithm>…

ABC114A - 753

ABC

問題:A - 753 #include <iostream> using namespace std; int main(void) { int x; cin.tie(0); ios::sync_with_stdio(false); cin >> x; cout << (x == 7 || x == 5 || x == 3? "YES" : "NO") << "\n"; return 0; }</iostream>

ABC113B - Palace

ABC

問題:B - Palace #include <cstdlib> #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, t, a, h, min_a = INF, min_pos = 0; cin.tie(0); ios::sync_with_stdio(false); cin >> n</iostream></cstdlib>…

ABC113A - Discount Fare

ABC

問題:A - Discount Fare #include <iostream> using namespace std; int main(void) { int x, y; cin.tie(0); ios::sync_with_stdio(false); cin >> x >> y; cout << x + y / 2; return 0; }</iostream>

ABC112B - Time Limit Exceeded

ABC

問題:B - Time Limit Exceeded #include <algorithm> #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, t, p_cost, p_time; vector<int> ret; cin.tie(0); ios::sync_with_stdio(f</int></vector></iostream></algorithm>…

ABC112A - Programming Education

ABC

問題:A - Programming Education #include <iostream> using namespace std; int main(void) { int n, a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> n; if (n == 1) { cout << "Hello World" << "\n"; } else { cin >> a >> b; cout << a + b << "\n"; } r</iostream>…

ABC111B - AtCoder Beginner Contest 111

ABC

問題:B - AtCoder Beginner Contest 111 #include <iostream> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) int main(void) { int n; cin.tie(0); ios::sync_with_stdio(false); cin >> n; FOR(i, n , 1000) { if (i == (i / 100) * 1</iostream>…

ABC111A - AtCoder Beginner Contest 999

ABC

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

ABC110B - 1 Dimensional World's Tale

ABC

問題:B - 1 Dimensional World's Tale #include <algorithm> #include <iostream> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) bool isWar(vector<int> vec_x, vector<int> vec_y) { return *max_element(vec_x.begin(), vec_x.end()) >= *min_elemen</int></int></vector></iostream></algorithm>…

ABC110A - Maximize the Formula

ABC

問題:A - Maximize the Formula #include <algorithm> #include <iostream> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void){ int num[3]; cin.tie(0); ios::sync_with_stdio(false); cin >> num[0] >> num[1] >> num[2]; sort(num, num +</iostream></algorithm>…

ABC109B - Shiritori

ABC

問題:B - Shiritori #include <iostream> #include <set> #include <vector> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void){ int n; vector<string> v_w(100); set<string> s_w; bool flg = true; cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP</string></string></vector></set></iostream>…

ABC109A - ABC333

ABC

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

ABC108B - Ruined Square

ABC

問題:B - Ruined Square #include <iostream> using namespace std; int main(void) { int x1, x2, y1, y2, a, b; cin.tie(0); ios::sync_with_stdio(false); cin >> x1 >> x2 >> y1 >> y2; a = y1 - x1; b = y2 - x2; cout << y1 - b << " " << y2 + a << " " << x1 </iostream>…

ABC108A - Pair

ABC

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

ABC107B - Grid Compression

ABC

問題:B - Grid Compression #include <iostream> #include <string> using namespace std; #define REP(i, n) for (int i = 0; i < (n); ++i) int main(void) { int h, w; string a[100]; bool col[100] = {false}, row[100] = {false}; cin.tie(0); ios::sync_with_stdio(fal</string></iostream>…

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>