結果

問題 No.1232 2^x = x
コンテスト
ユーザー yuly3
提出日時 2020-09-23 14:30:23
言語 Nim
(2.2.8)
コンパイル:
nim --nimcache=~ --hints:off -o:a.out -d:release cpp _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 648 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,657 ms
コンパイル使用メモリ 73,472 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-16 03:28:10
合計ジャッジ時間 4,173 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
/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, 70) Warning: imported and not used: 'sugar' [UnusedImport]
/home/judge/data/code/Main.nim(1, 44) Warning: imported and not used: 'sets' [UnusedImport]
/home/judge/data/code/Main.nim(1, 77) Warning: imported and not used: 'tables' [UnusedImport]

ソースコード

diff #
raw source code

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