結果

問題 No.736 約比
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2018-12-29 13:19:06
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 790 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 65,144 KB
最終ジャッジ日時 2024-04-27 02:45:48
合計ジャッジ時間 1,266 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(35, 8) Error: undeclared identifier: 'lc'

ソースコード

diff #

import future, strutils


proc nextString: string =
   result = ""
   while not endOfFile stdin:
      let nextChar = readChar stdin
      case nextChar
      of '\r':
         discard
      of "\n"[0], ' ':
         break
      else:
         add result, nextChar


proc nextInt: int =
   return parseInt nextString()


proc gcd(x, y: int): int =
   var (a, b) = (x, y)
   if b > a:
      swap(a, b)
   while true:
      let c = a mod b
      if c == 0:
         return b
      a = b
      b = c


let
   n = nextInt()
   a = lc[nextInt() | (x <- 0..<n), int]


proc main: void =
   var k = a[0]
   for i in 1..<n:
      k = gcd(k, a[i])
   
   for i in 0..<n:
      if i != 0:
         write stdout, ":"
      write stdout, a[i] div k
   write stdout, "\n"


when isMainModule:
   main()
0