結果

問題 No.376 立方体のN等分 (2)
ユーザー sekiya9311sekiya9311
提出日時 2016-06-05 02:20:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,537 bytes
コンパイル時間 1,097 ms
コンパイル使用メモリ 118,360 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-04-17 03:50:36
合計ジャッジ時間 7,363 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

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(int 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