結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
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 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
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 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

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];
		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