素数

ABC300D - AABCC

考え方 回答例 考え方素数はエラトステネスの篩(ふるい)で列挙できる.$a^{5} $2^{2}\times 3 \times c^{2} \leq 10^{12}$より$c \leq 10^{6}/\sqrt{12} この範囲で全て調べれば良い.回答例 N = int(input()) MAX = 300000 prime = [] is_prime = [True] …

ARC137A - Coprime Pair

考え方 回答例 考え方「$y-x$を大きい方から順に調べて,初めて$\gcd(x,y) = 1$となるものを出力すれば,制限時間内に止まるだろう」という方針でうまくいく.コンテスト中に計算量まで考えるのはなかなか大変. Editorial - AtCoder Regular Contest 137回…