競技プログラミング

AOJ0022

Maximum Sum Sequence | Aizu Online Judge while True: n = int(input()) if n == 0: break s = [int(input())] for i in range(1, n): a = int(input()) s.append(max(a, a + s[i - 1])) print(max(s))

AOJ0021

Parallelism | Aizu Online Judge n = int(input()) for i in range(n): x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split()) c1 = (y1 - y2) * (x3 - x4) c2 = (y3 - y4) * (x1 - x2) if abs(c1 - c2) < 1e-10: print('YES') else: print('NO')

AOJ0020

Capitalize | Aizu Online Judge s = input() print(s.upper())

AOJ0019

Factorial | Aizu Online Judge from math import factorial n = int(input()) print(factorial(n))

AOJ0018

Sorting Five Numbers | Aizu Online Judge s = sorted(list(map(int, input().split())), reverse=True) print(s[0], s[1], s[2], s[3], s[4])

AOJ0017

Caesar Cipher | Aizu Online Judge #include <iostream> using namespace std; int main() { string s; while (getline(cin, s)) { while (true) { for (int i = 0; i < s.length(); ++i) { if (s[i] == ' ' || s[i] == '.') { continue; } if (s[i] == 'z') { s[i] -</iostream>…

競技プログラミングに関するメモ

C++ [C++] STLの型の使い分け - Qiita 競技プログラミングの入力メモ - 2冊の本を3等分 【C++】入出力のメモ - 緑茶思考ブログ Python Python3で競技プログラミングめも - くれなゐの雑記 Pythonで競技プログラミングする時に知っておきたいtips(入出力編) -…

AOJ0016

Treasure Hunt | Aizu Online Judge C++ だと,円周率ってどこに定義されているんだろう? #include <iostream> #include <cmath> using namespace std; int main() { const double PI = static_cast<double>(acos(-1.0)); pair<double, double> pos = {0.0, 0.0}; int angle = 90; int d, a; while (1</double,></double></cmath></iostream>…

AOJ0015

National Budget | Aizu Online Judge boost::multiprecision::cpp_int 的なものを実装する必要あり. 「入力される整数は 100 桁を超えない」ということに注意する. #include <iostream> using namespace std; struct big_int { static const int CAPACITY = 80; int</iostream>…

AOJ0014

Integral | Aizu Online Judge #include <iostream> using namespace std; int main() { int d; while (cin >> d) { int s = 0; for (int x = 0; x < 600; x += d) { s += x * x * d; } cout << s << endl; } return 0; }</iostream>

AOJ0013

Switching Railroad Cars | Aizu Online Judge #include <iostream> #include <stack> using namespace std; int main() { stack<int> s; int n; while (cin >> n) { if (n != 0) { s.push(n); } else { cout << s.top() << endl; s.pop(); } } return 0; }</int></stack></iostream>

AOJ 0012

A Point in a Triangle | Aizu Online Judge 外積を用いて判定します. #include <iostream> #include <array> using namespace std; class point { public: double x, y; double operator%(const point &p) const; point operator-(const point &p) const; }; // cross produ</array></iostream>…

AOJ 0011

Drawing Lots | Aizu Online Judge #include <iostream> #include <vector> #include <numeric> using namespace std; int main() { int w, n; cin >> w; cin >> n; vector<int> lots(w); iota(lots.begin(), lots.end(), 1); for (int i = 0; i < n; ++i) { pair<int, int> p; cin >> p.first; cin.ign</int,></int></numeric></vector></iostream>…

AOJ 0010

Circumscribed Circle of a Triangle | Aizu Online Judge 外接円の中心の座標を として,次の方程式を解く. つまり,次のような連立方程式を解けばよい. 解は次のようになる. 外接円の半径 は外接円の中心と 3 つのうちのひとつの点の Euclid 距離を求め…

AOJ 0009

Prime Number | Aizu Online Judge 普通に Eratosthenes の篩を用いる.実行時に素数を数えるより,予め計算しておいたほうがはやい. #include <iostream> #include <array> using namespace std; int main() { const int N = 1000000; array<bool, N> search_array; array<int, N> count_arra</int,></bool,></array></iostream>…