結果

問題 No.375 立方体のN等分 (1)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-07-19 15:42:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 66,156 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 16:48:48
合計ジャッジ時間 1,447 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

std::vector<long long int> vec;
long long int ans;

void f(int p,long long int a,long long int b,long long int c){
	if(vec.size()==p){
		ans=std::min(a+b+c-3,ans);
	}else{
		long long int e=vec[p];
		if(a<=b&&a<=c){
			f(p+1,a*e,b,c);
		}else if(b<=a&&b<=c){
			f(p+1,a,b*e,c);	
		}else{
			f(p+1,a,b,c*e);
		}
	}
}

int main() {
	// your code goes here
	long long int n,t;
	std::cin>>n;
	t=n;
	ans=n;
	for(long long int i=2;i*i<=n;i++){
		while(n%i==0){
			n/=i;
			vec.push_back(i);
		}
	}
	
	if(n>1){
		vec.push_back(n);
	}
	std::sort(vec.begin(),vec.end());
	std::reverse(vec.begin(),vec.end());
	f(0,1,1,1);
	std::cout<<ans<<" "<<t-1<<"\n";
	return 0;
}
0