結果
| 問題 |
No.375 立方体のN等分 (1)
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2019-01-24 18:58:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 5,000 ms |
| コード長 | 1,000 bytes |
| コンパイル時間 | 903 ms |
| コンパイル使用メモリ | 98,476 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 04:41:09 |
| 合計ジャッジ時間 | 2,117 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#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;
}
chocorusk