結果

問題 No.375 立方体のN等分 (1)
ユーザー noriocnorioc
提出日時 2016-06-05 13:35:02
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,012 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 112,852 KB
実行使用メモリ 25,572 KB
最終ジャッジ日時 2024-04-17 04:46:50
合計ジャッジ時間 3,169 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
17,536 KB
testcase_01 AC 21 ms
17,664 KB
testcase_02 RE -
testcase_03 AC 22 ms
17,792 KB
testcase_04 AC 21 ms
17,536 KB
testcase_05 AC 21 ms
17,792 KB
testcase_06 AC 770 ms
17,408 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 int Calc(int n) {
        // n = a * b * c
        // a + b + c - 3 の最小値を求める

        int ans = int.MaxValue;
        for (int i = 1; i * i * i <= n; i++) {
            if (n % i == 0) {
                int x = n / i;
                for (int j = i; j <= x; j++) {
                    if (x % j == 0) {
                        int y = x / j;

                        ans = Math.Min(ans, i + j + y - 3);
                    }
                }
            }
        }
        return ans;
    }

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