結果
| 問題 | No.376 立方体のN等分 (2) |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2015-05-06 00:32:28 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 863 bytes |
| 記録 | |
| コンパイル時間 | 1,665 ms |
| コンパイル使用メモリ | 182,164 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-03-27 04:39:14 |
| 合計ジャッジ時間 | 4,911 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 WA * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long loong;
map<loong,int> e;
loong p[20];int pn;
loong ae[20];
loong n,m,a,t;
// 皆さんは自前のライブラリで素因数分解してください (^^)
void factor(loong n){
char cmd[256];
sprintf(cmd,"factor %lld",n);
FILE* f=popen(cmd,"r");
loong x;
fscanf(f,"%lld:",&x);
while(fscanf(f,"%lld",&x)==1){
if(++e[x]==1){
p[pn++]=x;
}
}
fclose(f);
}
void find_b(loong b,int i){
if(i==pn){
loong c=m/b;
if(t>a+b+c-3){
t=a+b+c-3;
}
}else{
for(int d=0;d<=e[p[i]]-ae[i]&&b*b<=m;++d,b*=p[i]){
find_b(b,i+1);
}
}
}
void find_a(loong a,int i){
if(i==pn){
::a=a;
m=n/a;
find_b(1,0);
}else{
for(int d=0;d<=e[p[i]]&&a*a*a<=n;++d,a*=p[i]){
find_a(a,i+1);
}
}
}
int main(){
cin>>n;
factor(n);
t=n;
find_a(1,0);
cout<<t<<" "<<n-1<<endl;
return 0;
}
tails