結果

問題 No.376 立方体のN等分 (2)
ユーザー kotatsugamekotatsugame
提出日時 2020-02-16 07:26:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,789 ms / 5,000 ms
コード長 479 bytes
コンパイル時間 977 ms
コンパイル使用メモリ 76,960 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 03:29:58
合計ジャッジ時間 13,080 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 88 ms
5,376 KB
testcase_03 AC 87 ms
5,376 KB
testcase_04 AC 101 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 7 ms
5,376 KB
testcase_09 AC 23 ms
5,376 KB
testcase_10 AC 127 ms
5,376 KB
testcase_11 AC 47 ms
5,376 KB
testcase_12 AC 62 ms
5,376 KB
testcase_13 AC 65 ms
5,376 KB
testcase_14 AC 72 ms
5,376 KB
testcase_15 AC 80 ms
5,376 KB
testcase_16 AC 1,561 ms
5,376 KB
testcase_17 AC 89 ms
5,376 KB
testcase_18 AC 91 ms
5,376 KB
testcase_19 AC 94 ms
5,376 KB
testcase_20 AC 98 ms
5,376 KB
testcase_21 AC 1,577 ms
5,376 KB
testcase_22 AC 102 ms
5,376 KB
testcase_23 AC 1,624 ms
5,376 KB
testcase_24 AC 1,561 ms
5,376 KB
testcase_25 AC 103 ms
5,376 KB
testcase_26 AC 1,789 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 106 ms
5,376 KB
testcase_31 AC 105 ms
5,376 KB
testcase_32 AC 106 ms
5,376 KB
testcase_33 AC 106 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 105 ms
5,376 KB
testcase_38 AC 106 ms
5,376 KB
testcase_39 AC 107 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long N;
main()
{
	cin>>N;
	vector<long>div;
	for(long i=1;i*i<=N;i++)
	{
		if(N%i==0)
		{
			div.push_back(i);
			if(N/i>i)div.push_back(N/i);
		}
	}
	long ans=N-1;
	sort(div.begin(),div.end());
	for(int i=0;i<div.size();i++)
	{
		int j=i;
		while(j<div.size()&&div[i]<=N/div[j])
		{
			if(N%(div[i]*div[j])==0)ans=min(ans,div[i]+div[j]+N/div[i]/div[j]-3);
			j++;
		}
	}
	cout<<ans<<" "<<N-1<<endl;
}
0