結果

問題 No.375 立方体のN等分 (1)
ユーザー sekiya9311sekiya9311
提出日時 2016-06-05 00:40:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,944 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 114,096 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-04-17 03:31:08
合計ジャッジ時間 7,990 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <random>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

bool isPrime(LL a){
    if(a<2) return false;
    for(LL i=2;i*i<=a;i++){
        if(a%i==0) return false;
    }
    return true;
}

int main(void){
    LL N; cin>>N;
    vector<LL> v;
    LL tmin=0;
    if(N<=3) tmin=N-1;
    else{
        LL nbuf=N;
        for(int i=2;i*i<=nbuf;i++){
            if(isPrime(i)){
                while(nbuf%i==0){
                    nbuf/=i;
                    v.push_back(i);
                    if(nbuf==0) break;
                }
            }
            if(nbuf==0) break;
        }
        if(nbuf>1) v.push_back(nbuf);
        while(v.size()>4){
            int vs=v.size();
            REP(i,vs/2){
                v[i]*=v.back();
                v.pop_back();
            }
            //SORT(v);
        }
        if(v.size()==4){
            v[0]*=v[3]; v.pop_back();
        }
        tmin=accumulate(v.begin(), v.end(), 0)-v.size();
    }
    cout<<tmin<<" "<<N-1<<endl;
}
0