結果

問題 No.376 立方体のN等分 (2)
ユーザー 14番14番
提出日時 2016-09-10 23:43:59
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,710 bytes
コンパイル時間 3,091 ms
コンパイル使用メモリ 104,576 KB
実行使用メモリ 27,872 KB
最終ジャッジ日時 2024-04-28 10:06:59
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
17,664 KB
testcase_01 AC 20 ms
17,664 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 21 ms
17,536 KB
testcase_06 AC 21 ms
17,664 KB
testcase_07 WA -
testcase_08 AC 23 ms
17,536 KB
testcase_09 AC 20 ms
17,792 KB
testcase_10 AC 20 ms
17,664 KB
testcase_11 WA -
testcase_12 AC 21 ms
17,664 KB
testcase_13 AC 22 ms
17,664 KB
testcase_14 WA -
testcase_15 AC 28 ms
17,664 KB
testcase_16 AC 21 ms
17,408 KB
testcase_17 WA -
testcase_18 AC 28 ms
17,664 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 23 ms
17,536 KB
testcase_22 AC 26 ms
17,792 KB
testcase_23 AC 23 ms
17,536 KB
testcase_24 AC 23 ms
17,408 KB
testcase_25 AC 23 ms
17,536 KB
testcase_26 AC 23 ms
17,536 KB
testcase_27 AC 99 ms
17,536 KB
testcase_28 AC 22 ms
17,792 KB
testcase_29 WA -
testcase_30 AC 23 ms
17,664 KB
testcase_31 AC 123 ms
17,536 KB
testcase_32 AC 97 ms
17,408 KB
testcase_33 AC 123 ms
17,664 KB
testcase_34 AC 125 ms
17,408 KB
testcase_35 WA -
testcase_36 AC 125 ms
17,792 KB
testcase_37 AC 126 ms
17,408 KB
testcase_38 WA -
testcase_39 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.Text;
using System.Linq;



class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        long num = long.Parse(Reader.ReadLine());
        long ans = this.GetAns(num);

        Console.WriteLine(ans + " " + (num-1));
    }



    private long GetRippoukon(long num, long min, long max) {
        long mid = (min + max) / 2;
        long tmp = mid * mid * mid;
        if(tmp == num) {
            return mid;
        }
        if(tmp < 0 || tmp > num) {
            if(mid - min <= 1) {
                return min;
            } else {
                return this.GetRippoukon(num, min, mid);
            }
        } else {
            if(max-mid <= 1) {
                return mid;
            } else {
                return this.GetRippoukon(num, mid, max);
            }
        }
    }

    private long GetHeihoukon(long num, long min, long max) {
        long mid = (min + max) / 2;
        long tmp = mid * mid;
        if(tmp == num) {
            return mid;
        }
        if(tmp > num) {
            if(mid - min <= 1) {
                return min;
            } else {
                return this.GetHeihoukon(num, min, mid);
            }
        } else {
            if(max - mid <= 1) {
                return mid;
            } else {
                return this.GetHeihoukon(num, mid, max);
            }
        }
    }
    private long GetAns(long num) {
        int num1 = 1;
        long rippou = this.GetRippoukon(num, 1, this.GetHeihoukon(num, 1, Math.Min(num, 1000000000)));
        for(int i=1; i<=rippou; i++) {
            if(num % i == 0) {
                num1 = i;
            }
        }

        long nokori = num / num1;
        int num2 = 1;
        long heihou = this.GetHeihoukon(nokori, 1, Math.Min(nokori, 1000000000));
        for(int i=1; i<=heihou; i++) {
            if(nokori % i == 0) {
                num2 = i;
            }
        }

        return (num1 - 1) + (num2 - 1) + (nokori / num2 - 1);

    }




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


12




";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0