結果

問題 No.375 立方体のN等分 (1)
ユーザー noriocnorioc
提出日時 2016-06-05 13:44:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 1,062 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 110,968 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-04-20 02:10:56
合計ジャッジ時間 3,318 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
17,664 KB
testcase_01 AC 22 ms
17,536 KB
testcase_02 AC 40 ms
17,408 KB
testcase_03 AC 22 ms
17,792 KB
testcase_04 AC 21 ms
17,664 KB
testcase_05 AC 21 ms
17,408 KB
testcase_06 AC 22 ms
17,664 KB
testcase_07 AC 23 ms
17,408 KB
testcase_08 AC 33 ms
17,536 KB
testcase_09 AC 25 ms
17,664 KB
testcase_10 AC 27 ms
17,536 KB
testcase_11 AC 25 ms
17,408 KB
testcase_12 AC 28 ms
17,536 KB
testcase_13 AC 29 ms
17,536 KB
testcase_14 AC 67 ms
17,536 KB
testcase_15 AC 31 ms
17,664 KB
testcase_16 AC 29 ms
17,536 KB
testcase_17 AC 96 ms
17,792 KB
testcase_18 AC 75 ms
17,408 KB
testcase_19 AC 31 ms
17,536 KB
testcase_20 AC 25 ms
17,408 KB
testcase_21 AC 24 ms
17,920 KB
testcase_22 AC 121 ms
17,664 KB
testcase_23 AC 28 ms
17,792 KB
testcase_24 AC 25 ms
17,792 KB
testcase_25 AC 39 ms
17,792 KB
testcase_26 AC 28 ms
17,664 KB
testcase_27 AC 30 ms
17,536 KB
testcase_28 AC 25 ms
17,664 KB
testcase_29 AC 25 ms
17,408 KB
testcase_30 AC 26 ms
17,664 KB
testcase_31 AC 27 ms
17,664 KB
testcase_32 AC 25 ms
17,536 KB
testcase_33 AC 27 ms
17,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

class Program {
    static string ReadLine() { return Console.ReadLine(); }
    static int ReadInt() { return int.Parse(ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static long Calc(long n) {
        // n = a * b * c
        // a + b + c - 3 の最小値を求める

        long ans = long.MaxValue;
        for (long i = 1; i * i * i <= n; i++) {
            if (n % i == 0) {
                long x = n / i;
                for (long j = i; j * j <= x; j++) {
                    if (x % j == 0) {
                        long y = x / j;
                        ans = Math.Min(ans, i + j + y - 3);                        
                    }
                }
            }
        }
        return ans;
    }

    static void Main() {
        long n = long.Parse(ReadLine());
        long ans = Calc(n);
        Console.WriteLine("{0} {1}", ans, n-1);
    }
}
0