結果
問題 | No.732 3PrimeCounting |
ユーザー | kei |
提出日時 | 2018-09-07 22:05:22 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,178 bytes |
コンパイル時間 | 1,726 ms |
コンパイル使用メモリ | 169,264 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-05-07 01:53:30 |
合計ジャッジ時間 | 41,226 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
10,752 KB |
testcase_01 | AC | 5 ms
5,376 KB |
testcase_02 | AC | 5 ms
5,376 KB |
testcase_03 | AC | 4 ms
5,376 KB |
testcase_04 | AC | 4 ms
5,376 KB |
testcase_05 | AC | 5 ms
5,376 KB |
testcase_06 | AC | 4 ms
5,376 KB |
testcase_07 | AC | 4 ms
5,376 KB |
testcase_08 | AC | 4 ms
5,376 KB |
testcase_09 | AC | 4 ms
5,376 KB |
testcase_10 | AC | 4 ms
5,376 KB |
testcase_11 | AC | 5 ms
5,376 KB |
testcase_12 | AC | 4 ms
5,376 KB |
testcase_13 | AC | 4 ms
5,376 KB |
testcase_14 | AC | 4 ms
5,376 KB |
testcase_15 | AC | 4 ms
5,376 KB |
testcase_16 | AC | 4 ms
5,376 KB |
testcase_17 | AC | 4 ms
5,376 KB |
testcase_18 | AC | 4 ms
5,376 KB |
testcase_19 | AC | 5 ms
5,376 KB |
testcase_20 | AC | 5 ms
5,376 KB |
testcase_21 | AC | 8 ms
5,376 KB |
testcase_22 | AC | 8 ms
5,376 KB |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 4 ms
5,376 KB |
testcase_25 | AC | 15 ms
5,376 KB |
testcase_26 | AC | 9 ms
5,376 KB |
testcase_27 | AC | 5 ms
5,376 KB |
testcase_28 | AC | 4 ms
5,376 KB |
testcase_29 | AC | 6 ms
5,376 KB |
testcase_30 | AC | 6 ms
5,376 KB |
testcase_31 | AC | 8 ms
5,376 KB |
testcase_32 | AC | 11 ms
5,376 KB |
testcase_33 | AC | 12 ms
5,376 KB |
testcase_34 | AC | 12 ms
5,376 KB |
testcase_35 | AC | 9 ms
5,376 KB |
testcase_36 | AC | 9 ms
5,376 KB |
testcase_37 | AC | 4 ms
5,376 KB |
testcase_38 | AC | 4 ms
5,376 KB |
testcase_39 | AC | 9 ms
5,376 KB |
testcase_40 | AC | 8 ms
5,376 KB |
testcase_41 | AC | 8 ms
5,376 KB |
testcase_42 | AC | 8 ms
5,376 KB |
testcase_43 | AC | 7 ms
5,376 KB |
testcase_44 | AC | 7 ms
5,376 KB |
testcase_45 | AC | 5 ms
5,376 KB |
testcase_46 | AC | 5 ms
5,376 KB |
testcase_47 | AC | 5 ms
5,376 KB |
testcase_48 | AC | 17 ms
5,376 KB |
testcase_49 | AC | 18 ms
5,376 KB |
testcase_50 | AC | 7 ms
5,376 KB |
testcase_51 | AC | 8 ms
5,376 KB |
testcase_52 | AC | 5 ms
5,376 KB |
testcase_53 | AC | 58 ms
5,376 KB |
testcase_54 | AC | 1,277 ms
5,888 KB |
testcase_55 | AC | 1,267 ms
6,016 KB |
testcase_56 | AC | 1,276 ms
5,888 KB |
testcase_57 | AC | 209 ms
5,376 KB |
testcase_58 | AC | 207 ms
5,376 KB |
testcase_59 | AC | 65 ms
5,376 KB |
testcase_60 | AC | 346 ms
5,376 KB |
testcase_61 | AC | 332 ms
5,376 KB |
testcase_62 | AC | 1,748 ms
6,144 KB |
testcase_63 | AC | 696 ms
5,632 KB |
testcase_64 | AC | 441 ms
5,376 KB |
testcase_65 | AC | 443 ms
5,376 KB |
testcase_66 | AC | 5 ms
5,376 KB |
testcase_67 | AC | 5 ms
5,376 KB |
testcase_68 | AC | 1,526 ms
6,144 KB |
testcase_69 | AC | 1,493 ms
5,888 KB |
testcase_70 | AC | 1,328 ms
6,016 KB |
testcase_71 | AC | 1,333 ms
5,888 KB |
testcase_72 | AC | 624 ms
5,504 KB |
testcase_73 | AC | 2,928 ms
6,656 KB |
testcase_74 | AC | 2,909 ms
6,784 KB |
testcase_75 | AC | 16 ms
5,376 KB |
testcase_76 | AC | 1,472 ms
5,888 KB |
testcase_77 | AC | 227 ms
5,376 KB |
testcase_78 | AC | 2,209 ms
6,400 KB |
testcase_79 | AC | 1,514 ms
6,144 KB |
testcase_80 | AC | 1,964 ms
6,400 KB |
testcase_81 | AC | 1,330 ms
6,016 KB |
testcase_82 | AC | 5 ms
5,376 KB |
testcase_83 | AC | 231 ms
5,376 KB |
testcase_84 | AC | 248 ms
5,376 KB |
testcase_85 | AC | 1,101 ms
6,016 KB |
testcase_86 | AC | 2,018 ms
6,272 KB |
testcase_87 | TLE | - |
testcase_88 | -- | - |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; } template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; } template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; } template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; } /* <url:> 問題文============================================================ ================================================================= 解説============================================================= ================================================================ */ const ll MAX_PRIME = 300050; vector<int> primes; vector<int> is_prime(MAX_PRIME + 1,true); void init_primes(){ is_prime[0] = is_prime[1] = false; for(int i = 2; i <= MAX_PRIME;i++){ if(is_prime[i]){ primes.push_back(i); for(int j = i*2; j <= MAX_PRIME; j+=i) is_prime[j] = false; } } } int dp[4][MAX_PRIME]; ll solve(){ init_primes(); ll res = 0; ll N; cin >> N; dp[0][0] = 1; for(int i = 0; i < primes.size();i++){ if(N < primes[i]) continue; for(int j = 2; j >= 0;j--){ for(int k = 3*primes[i]; k >= 0;k--){ if(dp[j][k] == 0) continue; dp[j+1][k+primes[i]] += dp[j][k]; } } } for(int i = 0; i <= 3*N;i++){ if(is_prime[i]){ res += dp[3][i]; } } return res; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); cout << solve() << endl; return 0; }