結果

問題 No.1737 One to N
ユーザー ripityripity
提出日時 2021-11-12 21:46:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 2,025 ms
コンパイル使用メモリ 71,624 KB
実行使用メモリ 56,344 KB
最終ジャッジ日時 2023-08-17 00:45:58
合計ジャッジ時間 6,983 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,140 KB
testcase_01 AC 116 ms
55,516 KB
testcase_02 AC 116 ms
55,912 KB
testcase_03 AC 118 ms
56,300 KB
testcase_04 AC 117 ms
55,780 KB
testcase_05 AC 117 ms
55,868 KB
testcase_06 AC 118 ms
55,792 KB
testcase_07 AC 119 ms
56,056 KB
testcase_08 AC 118 ms
56,032 KB
testcase_09 AC 117 ms
55,760 KB
testcase_10 AC 117 ms
55,660 KB
testcase_11 AC 117 ms
56,344 KB
testcase_12 AC 117 ms
55,884 KB
testcase_13 AC 119 ms
56,224 KB
testcase_14 AC 117 ms
55,572 KB
testcase_15 AC 117 ms
56,340 KB
testcase_16 AC 116 ms
55,716 KB
testcase_17 AC 116 ms
55,872 KB
testcase_18 AC 123 ms
55,716 KB
testcase_19 AC 127 ms
55,716 KB
testcase_20 AC 128 ms
55,788 KB
testcase_21 AC 127 ms
55,772 KB
testcase_22 AC 122 ms
55,868 KB
testcase_23 AC 119 ms
55,748 KB
testcase_24 AC 117 ms
56,228 KB
testcase_25 AC 119 ms
56,164 KB
testcase_26 AC 119 ms
55,964 KB
testcase_27 AC 123 ms
56,256 KB
testcase_28 AC 118 ms
56,248 KB
testcase_29 AC 121 ms
56,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        for( int i = 2; i*i <= N; i++ ) {
            while( N%i == 0 ) {
                ans += i;
                N /= i;
            }
        }
        
        if( N != 1 ) ans += N;
        System.out.println(ans);
        
    }
    
}
0