結果

問題 No.375 立方体のN等分 (1)
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-07-15 22:06:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,038 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 68,884 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 02:00:24
合計ジャッジ時間 1,990 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

const int INF = 1e9;
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.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