結果

問題 No.375 立方体のN等分 (1)
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-07-15 22:10:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 763 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 62,124 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 02:00:58
合計ジャッジ時間 2,074 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 26 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 17 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 8 ms
5,376 KB
testcase_11 AC 7 ms
5,376 KB
testcase_12 AC 9 ms
5,376 KB
testcase_13 AC 9 ms
5,376 KB
testcase_14 AC 58 ms
5,376 KB
testcase_15 AC 13 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 98 ms
5,376 KB
testcase_18 AC 66 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 6 ms
5,376 KB
testcase_22 AC 125 ms
5,376 KB
testcase_23 AC 9 ms
5,376 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 23 ms
5,376 KB
testcase_26 AC 9 ms
5,376 KB
testcase_27 AC 13 ms
5,376 KB
testcase_28 AC 6 ms
5,376 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 AC 8 ms
5,376 KB
testcase_31 AC 11 ms
5,376 KB
testcase_32 AC 6 ms
5,376 KB
testcase_33 AC 9 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:38: warning: ‘c’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |                 ans = min(ans, a + b + c - 3);
      |                                ~~~~~~^~~
main.cpp:24:34: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |                 ans = min(ans, a + b + c - 3);
      |                                ~~^~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

const ll INF = 1e16;
int main(void){
    ll n; cin >> n;
    ll tmp = n;
    ll a, b, c, ans = INF;
    
    for (ll i = 1; i <= pow((double)n + 1, 1.0 / 3.0); ++i){
        if(n % i == 0){
            a = i;
            n /= a;
            for (ll j = 1; j <= sqrt((double)n) + 1; ++j){
                if(n % j == 0){
                    b = j;
                    c = n / j;
                }
                ans = min(ans, a + b + c - 3);
                // printf("%lld %lld %lld\n", a, b, c);
            }
        }
        n = tmp;
    }
    printf("%lld %lld\n", ans, tmp - 1);	
    return 0;
}
0