結果

問題 No.2795 Perfect Number
ユーザー 6soukiti296soukiti29
提出日時 2024-07-13 21:07:36
言語 Nim
(2.2.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 345 bytes
コンパイル時間 4,025 ms
コンパイル使用メモリ 65,292 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-13 21:07:42
合計ジャッジ時間 5,788 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 36) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import sequtils,strutils,algorithm,math


var
    N = stdin.readline.parseInt
    a = 0
    i = 1
if N > 137438691328:
    echo("No")
else:
    while i * i <= N:
        if N mod i == 0:
            a += i
            if i * i != N:
                a += N div i
        i += 1

    if a == 2 * N:
        echo("Yes")
    else:
        echo("No")
0