結果
問題 | No.546 オンリー・ワン |
ユーザー | ayaoni |
提出日時 | 2020-12-09 01:38:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 772 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 81,708 KB |
実行使用メモリ | 64,592 KB |
最終ジャッジ日時 | 2023-10-19 02:59:08 |
合計ジャッジ時間 | 1,463 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,592 KB |
testcase_01 | AC | 39 ms
53,592 KB |
testcase_02 | AC | 38 ms
53,592 KB |
testcase_03 | AC | 38 ms
53,592 KB |
testcase_04 | AC | 38 ms
53,592 KB |
testcase_05 | AC | 38 ms
53,592 KB |
testcase_06 | AC | 38 ms
53,592 KB |
testcase_07 | AC | 45 ms
62,304 KB |
testcase_08 | AC | 47 ms
62,444 KB |
testcase_09 | AC | 53 ms
64,528 KB |
testcase_10 | AC | 54 ms
64,592 KB |
ソースコード
import sys from math import gcd sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) N,L,H = MI() C = LI() ans = 0 for i in range(1,1<<N): a = 1 r = 0 for j in range(N): if (i>>j) & 1: c = C[j] a = (a*c)//gcd(a,c) r += 1 if r % 2 == 0: ans -= r*(H//a-(L-1)//a) else: ans += r*(H//a-(L-1)//a) print(ans)