結果
問題 | No.376 立方体のN等分 (2) |
ユーザー | wakannyaai |
提出日時 | 2020-03-23 23:43:38 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,766 bytes |
コンパイル時間 | 2,003 ms |
コンパイル使用メモリ | 185,536 KB |
実行使用メモリ | 19,252 KB |
最終ジャッジ日時 | 2024-06-09 09:54:49 |
合計ジャッジ時間 | 8,899 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 6 ms
18,984 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 7 ms
18,956 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | RE | - |
testcase_18 | WA | - |
testcase_19 | RE | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 105 ms
18,776 KB |
testcase_37 | AC | 105 ms
18,816 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
ソースコード
#include "bits/stdc++.h" #include <random> #include <algorithm> #include <unordered_set> #define rep(i,n) for(int i = 0; i < n; i++) typedef long long ll; typedef unsigned long long ull; using namespace std; #define vll vector<vector<long long>> #define vl vector<long long> #define vi vector<int> #define vii vector<vector<int>> #define pb push_back #define pf push_front #define ld long double #define Sort(a) sort(a.begin(),a.end()) #define cSort(a,cmp) sort(a.begin(),a.end(),cmp) #define reSort(a) sort(a.rbegin(), a.rend()) static const ll llMAX = numeric_limits<long long>::max(); static const int intMAX = numeric_limits<int>::max(); static const ll llMIN = numeric_limits<long long>::min(); static const int intMIN = numeric_limits<int>::min(); static const ll d_5 = 100000; static const ll d9_7 = 1000000007; static const ll d_9 = 1000000000; static const double PI=3.14159265358979323846; template<class T> void Printvector(std::vector<T> &a){ int size = a.size(); rep(i,size){ cout<<a[i]<<" "; } cout<<endl; } template<class T> void Printvector(std::vector<std::vector<T>> &a){ int size = a.size(); rep(i,size){ int size2=a[i].size(); rep(j,size2){ cout<<a[i][j]<<" "; } cout<<endl; } cout<<endl; } template<class T> vector<T> getaccum(vector<T> a){ int size=a.size(); vector<T> ans(size); ans[0]=a[0]; for(int i=0;i<size-1;i++){ ans[i+1]=ans[i]+a[i+1]; //ans[i+1]%=d9_7; } return ans; } template<class T> vector<vector<T>> getaccum2D(vector<vector<T>> a){ int sizey=a.size(); int sizex=a[0].size(); vector<vector<T>> ans(sizey,vector<T>(sizex,0)); //ans=a; ans[0][0]=a[0][0]; for(int i=1;i<sizex;i++){ ans[0][i]=ans[0][i-1]+a[0][i]; } for(int i=1;i<sizex;i++){ ans[i][0]=ans[i-1][0]+a[i][0]; } for (int i = 0; i < sizey-1; i++) for (int j = 0; j < sizex-1; j++) ans[i+1][j+1] = ans[i][j+1] + ans[i+1][j] - ans[i][j] + a[i+1][j+1]; return ans; } ll getaccumnum(vector<ll> accum,int l,int r){//閉区間[l,r]の総和 if(l==0){ return accum[r]; }else{ return accum[r]-accum[l-1]; } } template<class T> T getaccumnum2D(vector<vector<T>>& accum,int x1,int y1,int x2,int y2){//2の方が右下、閉区間 T ans=accum[y2][x2]; if(x1==0 && y1==0){ ; }else if(x1>0 && y1==0){ ans-=accum[y2][x1-1]; }else if(x1==0 && y1>0){ ans-=accum[y1-1][x2]; }else{ ans-=accum[y1-1][x2]; ans-=accum[y2][x1-1]; ans+=accum[y1-1][x1-1]; } return ans; } ll digitpower(ll a,ll b){//aのb乗を計算 if(b==1){ return a; }else if(b==0){ return 1; } int mode=0; if(b%2==1){ ll tmp = digitpower(a,(b-1)/2); if(mode==1){ tmp%=d9_7; } tmp*=tmp; if(mode==1){ tmp%=d9_7; } tmp*=a; if(mode==1){ return tmp%d9_7; }else{ return tmp; } }else{ ll tmp = digitpower(a,(b)/2); if(mode==1){ tmp%=d9_7; } tmp*=tmp; if(mode==1){ tmp%=d9_7; } if(mode==1){ return tmp%d9_7; }else{ return tmp; } } } vl facs(2000010,-1); ll Factrial(ll num){ if(facs[num]!=-1){ return facs[num]; } if(num==1||num<=0){ return 1; }else if(num<0){ printf("ERROR_minus\n"); return 0; }else{ facs[num]=(num*Factrial(num-1))%d9_7; return facs[num]; } } long long modinv(long long a, long long m) {//modの逆元 long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } /*vl invs(2000010,-1); ll linercomb(ll n,ll k, ll mod){//n,kの線形時間で求める if(n<k)return 0; if(n<0)return 0; if(k==0 || k==n)return 1; ll ans=Factrial(n); if(invs[k]==-1){ invs[k]=modinv(Factrial(k),mod); } ans*=invs[k]; ans%=d9_7; ll k1=Factrial(n-k); k1%=mod; ans*=modinv(k1,mod); ans%=mod; return ans; }*/ unordered_map<ll,ll> prime_factor(int64_t n) { unordered_map<ll,ll> ret; for(int64_t i = 2; i * i <= n; i++) { while(n % i == 0) { ret[i]++; n /= i; } } if(n != 1) ret[n] = 1; return ret; } struct datas{ ll p; ll q; };/* bool cmp(const datas &a, const datas &b) { return a.num < b.num; }*/ template<class T> T gcd(T a,T b){ if(a==0){ return b; }else if(b==0){ return a; } while(1) { if(a < b) swap(a, b); if(!b) break; a %= b; } return a; } int LCS(string s,string t) { int n=s.size(); int m=t.size(); vector<vector<int>> dp=vector<vector<int>>(n+1,vector<int>(m+1,0)); for (int i=0; i<n; ++i) { for (int j=0; j<m; ++j) { if (s[i] == t[j]) { dp[i+1][j+1] = dp[i][j] + 1; } else { dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]); } } } return dp[n][m]; } //約数列挙 vector< ll > divisor(ll n) { vector< ll > ret; for(ll i = 1; i * i <= n; i++) { if(n % i == 0) { ret.push_back(i); if(i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main(void){ ull n; cin>>n; vl p=divisor(n); int s=p.size(); ull ans=n-1; for(auto a:p){ for( auto b:p){ if(a<=1000000 || b<=100000000)continue; if(a*b>n)continue; auto c=n/(a*b); ans=min(ans,a+b+c-3); } } cout<<ans<<" "<<n-1<<endl; return 0; } //<<std::setprecision(30) //重複削除 /* std::sort(vec.begin(), vec.end()); vec.erase(std::unique(vec.begin(), vec.end()), vec.end());*/ //ペアの全探索 /*do{ int s=0; for(int i=0;i<n/2;i++)s+=v[i]^v[i+n/2]; r=max(s,r); reverse(v.begin()+n/2,v.end()); }while(next_permutation(v.begin(),v.end()));*/