結果
問題 | No.546 オンリー・ワン |
ユーザー |
![]() |
提出日時 | 2020-12-09 01:38:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 772 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 81,916 KB |
実行使用メモリ | 65,828 KB |
最終ジャッジ日時 | 2024-09-18 23:05:11 |
合計ジャッジ時間 | 1,216 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
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)