結果

問題 No.376 立方体のN等分 (2)
ユーザー sekiya9311sekiya9311
提出日時 2016-06-05 02:22:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 178 ms / 5,000 ms
コード長 1,536 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 118,736 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 13:46:17
合計ジャッジ時間 5,856 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 88 ms
5,376 KB
testcase_03 AC 84 ms
5,376 KB
testcase_04 AC 102 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 23 ms
5,376 KB
testcase_10 AC 36 ms
5,376 KB
testcase_11 AC 47 ms
5,376 KB
testcase_12 AC 62 ms
5,376 KB
testcase_13 AC 64 ms
5,376 KB
testcase_14 AC 72 ms
5,376 KB
testcase_15 AC 80 ms
5,376 KB
testcase_16 AC 149 ms
5,376 KB
testcase_17 AC 88 ms
5,376 KB
testcase_18 AC 91 ms
5,376 KB
testcase_19 AC 94 ms
5,376 KB
testcase_20 AC 97 ms
5,376 KB
testcase_21 AC 162 ms
5,376 KB
testcase_22 AC 100 ms
5,376 KB
testcase_23 AC 168 ms
5,376 KB
testcase_24 AC 167 ms
5,376 KB
testcase_25 AC 104 ms
5,376 KB
testcase_26 AC 178 ms
5,376 KB
testcase_27 AC 105 ms
5,376 KB
testcase_28 AC 105 ms
5,376 KB
testcase_29 AC 105 ms
5,376 KB
testcase_30 AC 105 ms
5,376 KB
testcase_31 AC 105 ms
5,376 KB
testcase_32 AC 104 ms
5,376 KB
testcase_33 AC 105 ms
5,376 KB
testcase_34 AC 105 ms
5,376 KB
testcase_35 AC 105 ms
5,376 KB
testcase_36 AC 105 ms
5,376 KB
testcase_37 AC 104 ms
5,376 KB
testcase_38 AC 106 ms
5,376 KB
testcase_39 AC 106 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <random>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

vector<LL> enumDiv(LL a){
	vector<LL> res;
	for(LL i=1;i*i<=a;i++){
		if(a%i==0){
			res.push_back(i);
			if(i*i!=a) res.push_back(a/i);
		}
	}
	SORT(res);
	return res;
}

int main(void){
    LL N; cin>>N;
    LL tmin=N-1;
    vector<LL> nd=enumDiv(N);
	for(LL i=0;nd[i]<=(LL)1000000 && nd[i]*nd[i]*nd[i]<=N;i++){
		for(LL j=i;nd[j]<=(LL)100000000 && nd[i]*nd[j]*nd[j]<=N;j++){
			if(N%(nd[i]*nd[j])==0){
				LL num=nd[i]+nd[j]+N/(nd[i]*nd[j])-3;
				tmin=min(tmin,num);
			}
		}
	}
    cout<<tmin<<" "<<N-1<<endl;
}
0