結果

問題 No.546 オンリー・ワン
ユーザー t8m8⛄️t8m8⛄️
提出日時 2017-07-22 00:40:45
言語 Nim
(2.0.2)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 689 bytes
コンパイル時間 3,675 ms
コンパイル使用メモリ 69,464 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 13:30:32
合計ジャッジ時間 4,025 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 RE -
testcase_08 AC 5 ms
4,380 KB
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 39) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 39) Warning: imported and not used: 'future' [UnusedImport]
/home/judge/data/code/Main.nim(1, 28) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import strutils, sequtils, algorithm, future, math

{.warning[SmallLshouldNotBeUsed]: off.}

proc cnt(x, n: int, a: seq[int]): int =
  for i in 0..<(1 shl a.len):
    if i.toBin(a.len+1).count('1') != n: continue
    var l = 1
    for j in 0..<a.len:
      if ((i shr j) and 1) != 1: continue
      l = lcm(l, a[j])
    result += (x div l)*n


when isMainModule:
  var
    input = stdin.readLine.split.map(parseInt)
    (n, l, h) = (input[0], input[1], input[2])
    a = stdin.readLine.split.map(parseInt)
    x, y: int64 = 0

  for i in 1..n:
    if i mod 2 == 1:
      x += cnt(l-1, i, a)
      y += cnt(h, i, a)
    else:
      x -= cnt(l-1, i, a)
      y -= cnt(h, i, a)

  echo y - x
0