結果

問題 No.376 立方体のN等分 (2)
ユーザー chocoruskchocorusk
提出日時 2019-01-22 12:23:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 440 ms / 5,000 ms
コード長 1,000 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 95,868 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 17:38:49
合計ジャッジ時間 6,318 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 30 ms
4,352 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 8 ms
4,352 KB
testcase_16 AC 383 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 7 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 3 ms
4,352 KB
testcase_21 AC 412 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 429 ms
4,352 KB
testcase_24 AC 363 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 440 ms
4,352 KB
testcase_27 AC 67 ms
4,348 KB
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 20 ms
4,348 KB
testcase_32 AC 69 ms
4,348 KB
testcase_33 AC 97 ms
4,352 KB
testcase_34 AC 48 ms
4,352 KB
testcase_35 AC 48 ms
4,348 KB
testcase_36 AC 98 ms
4,348 KB
testcase_37 AC 93 ms
4,348 KB
testcase_38 AC 26 ms
4,348 KB
testcase_39 AC 1 ms
4,348 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