結果

問題 No.375 立方体のN等分 (1)
ユーザー 👑 horiesinitihoriesiniti
提出日時 2016-07-19 15:27:53
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 62,004 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-23 16:48:19
合計ジャッジ時間 7,336 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 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 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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((a>b)||(a>c)||(b>c))return ;
	if(ans<a+b+c-3)return ;
	if(vec.size()==p){
		ans=std::min(a+b+c-3,ans);
	}else{
		long long int e=vec[p];
		f(p+1,a*e,b,c);
		f(p+1,a,b*e,c);
		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);
	}
	f(0,1,1,1);
	std::cout<<ans<<" "<<t-1<<"\n";
	return 0;
}
0