結果

問題 No.375 立方体のN等分 (1)
ユーザー chocoruskchocorusk
提出日時 2019-01-24 18:58:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 1,000 bytes
コンパイル時間 881 ms
コンパイル使用メモリ 95,996 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-14 09:42:16
合計ジャッジ時間 2,026 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
ll n0;
vector<P> f;
ll a, b;
ll tmin, tmax;
void dfs(int i){
	if(i==f.size()){
		tmin=min(tmin, a+b+n0/a/b-3);
		tmax=max(tmax, a+b+n0/a/b-3);
		return;
	}
	int e=f[i].second; ll pa=1, p=f[i].first;
	for(int j=0; j<=e; j++){
		ll pb=1;
		for(int k=0; k<=e-j; k++){
			a*=pa, b*=pb;
			dfs(i+1);
			a/=pa, b/=pb;
			pb*=p;
		}
		pa*=p;
	}
}
int main()
{
	ll n; cin>>n; n0=n;
	for(ll i=2; i*i<=n; i++){
		if(n%i==0){
			int e=0;
			while(n%i==0){
				n/=i; e++;
			}
			f.push_back(P(i, e));
		}
	}
	if(n>1) f.push_back(P(n, 1));
	a=1, b=1, tmin=n0-1, tmax=0;
	dfs(0);
	cout<<tmin<<" "<<tmax<<endl;
	return 0;
}
0