結果

問題 No.376 立方体のN等分 (2)
ユーザー kotarou777775kotarou777775
提出日時 2016-06-05 01:34:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,414 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 164,324 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 03:43:18
合計ジャッジ時間 6,447 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 81 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 95 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 21 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 45 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 60 ms
5,376 KB
testcase_14 AC 68 ms
5,376 KB
testcase_15 AC 76 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 82 ms
5,376 KB
testcase_18 AC 85 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 90 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 94 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 99 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 100 ms
5,376 KB
testcase_28 AC 101 ms
5,376 KB
testcase_29 AC 101 ms
5,376 KB
testcase_30 AC 101 ms
5,376 KB
testcase_31 AC 102 ms
5,376 KB
testcase_32 AC 101 ms
5,376 KB
testcase_33 AC 100 ms
5,376 KB
testcase_34 AC 100 ms
5,376 KB
testcase_35 AC 100 ms
5,376 KB
testcase_36 AC 97 ms
5,376 KB
testcase_37 AC 100 ms
5,376 KB
testcase_38 AC 99 ms
5,376 KB
testcase_39 AC 99 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a,c) memset(a,c,sizeof(a))

#define DEBUG(x) cout<<"#x"<<": "<<x<<endl

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = INT_MAX/3;
const ll MOD = 1000000007;
const double EPS = 1e-14;
const int dx[] = {1,0,-1,0} , dy[] = {0,1,0,-1};

void genDiv(ll n,vector<ll> &v){
    ll sn = sqrt( double(n) ) + 1;
    FOR(i,1,sn){
        if(n % ll(i) == 0){
            v.PB(i);
            v.PB(n/ll(i));
        }
    }
    sort(ALL(v));
}

int main(){
    ll n;
    cin >> n;
    ll sn = sqrt( double(n) ) + 1;
    ll sum = n*20LL;
    ll ans = n*20LL;

    vector<ll> v;
    genDiv(n,v);

    RREP(i,v.size()){
        ll a = v[i];
        ll b = n/v[i];
        ll tempans = 20LL * n;
        REP(j,i+1){
            ll ta = v[j];
            ll tb = a/ta;
            if( a != ta*tb ) continue;
            tempans = min(tempans , b + ta + tb - 3);
        }

        if(tempans > ans ) break;
        ans = tempans;
    }

    cout << ans << " " << n-1LL <<  endl;


    return 0;
}


0