結果

問題 No.1232 2^x = x
ユーザー yuly3yuly3
提出日時 2020-09-23 14:30:23
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 648 bytes
コンパイル時間 3,138 ms
コンパイル使用メモリ 67,920 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 07:12:13
合計ジャッジ時間 3,605 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'algorithm' [UnusedImport]
/home/judge/data/code/Main.nim(1, 19) Warning: imported and not used: 'deques' [UnusedImport]
/home/judge/data/code/Main.nim(1, 27) Warning: imported and not used: 'heapqueue' [UnusedImport]
/home/judge/data/code/Main.nim(1, 77) Warning: imported and not used: 'tables' [UnusedImport]
/home/judge/data/code/Main.nim(1, 44) Warning: imported and not used: 'sets' [UnusedImport]
/home/judge/data/code/Main.nim(1, 50) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 70) Warning: imported and not used: 'sugar' [UnusedImport]

ソースコード

diff #

import algorithm, deques, heapqueue, math, sets, sequtils, strutils, sugar, tables

proc input*(): string =
    return stdin.readLine
proc chmax*[T: SomeNumber](num0: var T, num1: T) =
    num0 = max(num0, num1)
proc chmin*[T: SomeNumber](num0: var T, num1: T) =
    num0 = min(num0, num1)
proc `%=`*[T: SomeInteger](num0: var T, num1: T) =
    num0 = num0 mod num1

var
    ans: seq[int]

proc solve() =
    let N = input().parseInt

    var pi: int
    for _ in 0..<N:
        pi = input().parseInt
        if pi == 2:
            ans.add(2)
        else:
            ans.add((pi - 1)^2)
    echo ans.join("\n")

when is_main_module:
    solve()
0