結果

問題 No.546 オンリー・ワン
ユーザー 6soukiti296soukiti29
提出日時 2017-07-18 08:36:35
言語 Nim
(2.0.2)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 3,701 ms
コンパイル使用メモリ 69,264 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 13:20:48
合計ジャッジ時間 4,064 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 5 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(30, 27) Warning: Number of spaces around '-' is not consistent [Spacing]
/home/judge/data/code/Main.nim(26, 17) Warning: The bare except clause is deprecated; use `except CatchableError:` instead [BareExcept]

ソースコード

diff #

import sequtils,strutils,math

proc p2(i : int): int=
    1 shl i

var
    N,L,H,i,p,cnt : int
    C,A : seq[int]
(N,L,H) = stdin.readline.split.map(parseInt)
C = stdin.readline.split.map(parseInt)
cnt = 0
for c in C:
    cnt += H div c
    cnt -= (L - 1) div c
for i in 0..p2(N):
    A = @[]
    for k in 0..N - 1:
        if (i and p2(k)) > 0:
            A.add(C[k])
    if A.len > 1:
        p = 1
        block hantei:
            for a in A:
                try:
                    p = p * a div gcd(p, a)
                except:
                    break hantei
            if A.len mod 2 == 0:
                cnt -= (H div p) * A.len
                cnt += ((L- 1) div p) * A.len
            else:
                cnt += (H div p) * A.len
                cnt -= ((L - 1) div p) * A.len
echo cnt
0