結果
| 問題 |
No.546 オンリー・ワン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-02 17:18:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 143 ms / 2,000 ms |
| コード長 | 696 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 82,396 KB |
| 実行使用メモリ | 89,472 KB |
| 最終ジャッジ日時 | 2024-06-29 02:02:21 |
| 合計ジャッジ時間 | 2,514 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
#!/usr/bin/env python3
# from typing import *
import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq
def input():
return sys.stdin.readline()[:-1]
# sys.setrecursionlimit(1000000)
# _INPUT = """2 1 10
# 2 3
# """
# sys.stdin = io.StringIO(_INPUT)
def get_lcm(a, b):
return a * b // math.gcd(a, b)
N, L, H = map(int, input().split())
C = list(map(int, input().split()))
ans = 0
for s in range(1, 2**N):
d = 1
m = 0
for i in range(N):
if s & (1<<i):
d = get_lcm(d, C[i])
m += 1
n = H//d - (L-1)//d
if m % 2 == 1:
ans += m*n
else:
ans -= m*n
print(ans)