結果

問題 No.375 立方体のN等分 (1)
ユーザー AreTrashAreTrash
提出日時 2016-06-04 23:09:06
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 979 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 107,008 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-17 01:03:15
合計ジャッジ時間 3,777 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
18,688 KB
testcase_01 AC 28 ms
18,432 KB
testcase_02 WA -
testcase_03 RE -
testcase_04 AC 27 ms
18,560 KB
testcase_05 AC 27 ms
18,304 KB
testcase_06 AC 28 ms
18,560 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 42 ms
18,712 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 68 ms
19,072 KB
testcase_24 AC 69 ms
19,072 KB
testcase_25 WA -
testcase_26 AC 70 ms
19,200 KB
testcase_27 WA -
testcase_28 AC 69 ms
19,072 KB
testcase_29 AC 67 ms
19,200 KB
testcase_30 AC 70 ms
19,072 KB
testcase_31 AC 68 ms
19,072 KB
testcase_32 AC 68 ms
19,072 KB
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

namespace No375{
    public class Program{
        public static void Main(string[] args){
            var N = long.Parse(Console.ReadLine());
            var input = N;
            var rl = new List<int>();

            if(input > 1){
                var nl = Enumerable.Range(2, (int)Math.Sqrt(input)).ToList();
                var sqrt = (int)Math.Sqrt(Math.Sqrt(input)) + 1;
                while(nl[0] <= sqrt){
                    var prime = nl[0];
                    rl.Add(prime);
                    nl.RemoveAll(value => value % prime == 0);
                }
                rl.AddRange(nl);
            }

            var res = 0L;
            foreach(var i in rl){
                while(N % i == 0){
                    N /= i;
                    res += i - 1;
                }
            }
            res += N - 1;

            Console.WriteLine("{0} {1}", res, input - 1);
        }
    }
}
0