結果

問題 No.458 異なる素数の和
ユーザー mfbgjsczmfbgjscz
提出日時 2019-08-13 19:52:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 170,096 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 17:15:50
合計ジャッジ時間 3,188 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 25 ms
4,348 KB
testcase_02 AC 28 ms
4,348 KB
testcase_03 AC 14 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 41 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 6 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 10 ms
4,348 KB
testcase_10 AC 5 ms
4,348 KB
testcase_11 AC 45 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 5 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 11 ms
4,348 KB
testcase_17 AC 6 ms
4,348 KB
testcase_18 AC 5 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 6 ms
4,348 KB
testcase_24 AC 5 ms
4,348 KB
testcase_25 AC 5 ms
4,348 KB
testcase_26 AC 5 ms
4,348 KB
testcase_27 AC 26 ms
4,348 KB
testcase_28 AC 44 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 21 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main(){
  vector<int>prinum(20010,0);
  rep(i,2,20010)if(is_prime(i))prinum[i]=1;
  lli A,B,C,D,N;
  cin >> N;
  vector<lli>DP(20010,-1);
  DP[0]=0;
  rep(i,2,20001){
    if(prinum[i]){
      DP[i]=0;
      for(int j=N;j>1;j--){
        if(i+j<=N&&DP[j]!=-1){
          chmax(DP[i+j],DP[j]+1);
        }
      }
    }
  }
  Out(DP[N]);
}
0