結果

問題 No.546 オンリー・ワン
コンテスト
ユーザー 6soukiti29
提出日時 2017-07-18 08:36:35
言語 Nim
(2.2.6)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 805 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 664 ms
コンパイル使用メモリ 65,152 KB
最終ジャッジ日時 2026-03-19 18:18:50
合計ジャッジ時間 1,400 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(30, 27) Warning: Number of spaces around '-' is not consistent [Spacing]
/home/judge/data/code/Main.nim(9, 35) Error: tuple expected for tuple unpacking, but got 'seq[int]'

ソースコード

diff #
raw source code

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