結果
問題 | No.732 3PrimeCounting |
ユーザー | kei |
提出日時 | 2018-09-07 22:01:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,227 bytes |
コンパイル時間 | 1,700 ms |
コンパイル使用メモリ | 170,556 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-29 13:38:01 |
合計ジャッジ時間 | 125,582 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
13,088 KB |
testcase_01 | AC | 8 ms
13,348 KB |
testcase_02 | AC | 9 ms
13,092 KB |
testcase_03 | AC | 10 ms
13,344 KB |
testcase_04 | AC | 9 ms
13,640 KB |
testcase_05 | AC | 10 ms
13,092 KB |
testcase_06 | AC | 11 ms
13,636 KB |
testcase_07 | AC | 9 ms
13,092 KB |
testcase_08 | AC | 11 ms
12,068 KB |
testcase_09 | AC | 11 ms
13,220 KB |
testcase_10 | AC | 11 ms
13,092 KB |
testcase_11 | AC | 10 ms
13,088 KB |
testcase_12 | AC | 11 ms
13,088 KB |
testcase_13 | AC | 11 ms
13,092 KB |
testcase_14 | AC | 12 ms
13,636 KB |
testcase_15 | AC | 12 ms
12,968 KB |
testcase_16 | AC | 12 ms
13,224 KB |
testcase_17 | AC | 12 ms
13,636 KB |
testcase_18 | AC | 13 ms
13,088 KB |
testcase_19 | AC | 13 ms
13,216 KB |
testcase_20 | AC | 110 ms
13,636 KB |
testcase_21 | AC | 352 ms
13,092 KB |
testcase_22 | AC | 330 ms
13,640 KB |
testcase_23 | AC | 43 ms
13,088 KB |
testcase_24 | AC | 44 ms
13,636 KB |
testcase_25 | AC | 594 ms
13,088 KB |
testcase_26 | AC | 447 ms
13,636 KB |
testcase_27 | AC | 144 ms
12,964 KB |
testcase_28 | AC | 144 ms
13,216 KB |
testcase_29 | AC | 277 ms
12,964 KB |
testcase_30 | AC | 268 ms
13,640 KB |
testcase_31 | AC | 354 ms
13,092 KB |
testcase_32 | AC | 487 ms
13,636 KB |
testcase_33 | AC | 488 ms
13,640 KB |
testcase_34 | AC | 495 ms
13,632 KB |
testcase_35 | AC | 389 ms
13,092 KB |
testcase_36 | AC | 391 ms
13,216 KB |
testcase_37 | AC | 74 ms
12,964 KB |
testcase_38 | AC | 74 ms
6,816 KB |
testcase_39 | AC | 401 ms
6,820 KB |
testcase_40 | AC | 368 ms
6,820 KB |
testcase_41 | AC | 366 ms
6,820 KB |
testcase_42 | AC | 372 ms
6,820 KB |
testcase_43 | AC | 301 ms
6,816 KB |
testcase_44 | AC | 297 ms
6,820 KB |
testcase_45 | AC | 175 ms
6,820 KB |
testcase_46 | AC | 175 ms
6,816 KB |
testcase_47 | AC | 218 ms
6,816 KB |
testcase_48 | AC | 625 ms
6,816 KB |
testcase_49 | AC | 636 ms
6,820 KB |
testcase_50 | AC | 340 ms
6,820 KB |
testcase_51 | AC | 351 ms
6,820 KB |
testcase_52 | AC | 159 ms
6,816 KB |
testcase_53 | AC | 1,142 ms
6,820 KB |
testcase_54 | TLE | - |
testcase_55 | TLE | - |
testcase_56 | TLE | - |
testcase_57 | AC | 2,209 ms
6,824 KB |
testcase_58 | AC | 2,422 ms
6,816 KB |
testcase_59 | AC | 1,251 ms
6,820 KB |
testcase_60 | AC | 2,835 ms
6,820 KB |
testcase_61 | AC | 2,879 ms
7,556 KB |
testcase_62 | TLE | - |
testcase_63 | TLE | - |
testcase_64 | TLE | - |
testcase_65 | TLE | - |
testcase_66 | AC | 39 ms
6,820 KB |
testcase_67 | AC | 37 ms
6,816 KB |
testcase_68 | TLE | - |
testcase_69 | TLE | - |
testcase_70 | TLE | - |
testcase_71 | TLE | - |
testcase_72 | TLE | - |
testcase_73 | TLE | - |
testcase_74 | TLE | - |
testcase_75 | AC | 584 ms
6,820 KB |
testcase_76 | TLE | - |
testcase_77 | AC | 2,352 ms
6,816 KB |
testcase_78 | TLE | - |
testcase_79 | TLE | - |
testcase_80 | TLE | - |
testcase_81 | TLE | - |
testcase_82 | AC | 130 ms
6,820 KB |
testcase_83 | AC | 2,283 ms
6,816 KB |
testcase_84 | AC | 2,431 ms
6,816 KB |
testcase_85 | TLE | - |
testcase_86 | TLE | - |
testcase_87 | TLE | - |
testcase_88 | TLE | - |
ソースコード
#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; } } } ll 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 = MAX_PRIME; 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]){ // cout << i << " " << dp[3][i] << endl; res += dp[3][i]; } } return res; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); cout << solve() << endl; return 0; }