結果
問題 | No.375 立方体のN等分 (1) |
ユーザー |
![]() |
提出日時 | 2016-06-05 13:42:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,077 bytes |
コンパイル時間 | 897 ms |
コンパイル使用メモリ | 110,456 KB |
実行使用メモリ | 33,280 KB |
最終ジャッジ日時 | 2024-10-08 15:39:02 |
合計ジャッジ時間 | 7,888 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 TLE * 1 -- * 24 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 <= x; j++) { if (x % j == 0) { long y = x / j; ans = Math.Min(ans, i + j + y - 3); if (y <= j) break; } } } } return ans; } static void Main() { long n = long.Parse(ReadLine()); long ans = Calc(n); Console.WriteLine("{0} {1}", ans, n-1); } }