結果

問題 No.458 異なる素数の和
ユーザー tlllunetlllune
提出日時 2018-11-10 16:22:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 86,332 KB
実行使用メモリ 11,012 KB
最終ジャッジ日時 2023-08-16 03:49:33
合計ジャッジ時間 3,082 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,860 KB
testcase_01 AC 5 ms
10,744 KB
testcase_02 AC 5 ms
10,808 KB
testcase_03 AC 5 ms
11,012 KB
testcase_04 AC 5 ms
10,748 KB
testcase_05 AC 5 ms
10,748 KB
testcase_06 AC 5 ms
10,776 KB
testcase_07 AC 5 ms
10,860 KB
testcase_08 AC 5 ms
10,804 KB
testcase_09 AC 6 ms
10,744 KB
testcase_10 AC 6 ms
10,812 KB
testcase_11 WA -
testcase_12 AC 5 ms
10,772 KB
testcase_13 AC 6 ms
10,808 KB
testcase_14 AC 6 ms
10,744 KB
testcase_15 AC 6 ms
10,804 KB
testcase_16 AC 6 ms
10,804 KB
testcase_17 AC 6 ms
10,936 KB
testcase_18 AC 6 ms
10,748 KB
testcase_19 AC 6 ms
10,760 KB
testcase_20 AC 5 ms
10,800 KB
testcase_21 AC 5 ms
10,840 KB
testcase_22 AC 5 ms
10,748 KB
testcase_23 AC 5 ms
10,800 KB
testcase_24 AC 5 ms
10,992 KB
testcase_25 AC 5 ms
10,772 KB
testcase_26 AC 6 ms
10,748 KB
testcase_27 AC 5 ms
10,764 KB
testcase_28 WA -
testcase_29 AC 5 ms
10,748 KB
testcase_30 AC 4 ms
10,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <iomanip>
#include <utility>
#include <set>
#include <map>

using namespace std;

vector<int> sq;
int ssm=0,n;
int dp[100][20010];
bool f;

int main(){
    for(int i=2;ssm<20000;i++){
        f=true;
        for(int j:sq)f=f and (i%j!=0);
        if(f){
            ssm+=i;
            sq.push_back(i);
        }
    }
    scanf("%d",&n);
    for(int i=0;i<20000;i++)dp[0][i]=0;
    for(int j=1;j<=92;j++){
        for(int i=19999;i>=0;i--){
            dp[j][i]=dp[j-1][i];
            if((i==0 or dp[j-1][i]!=0) and sq[j-1]+i<20000)dp[j][i+sq[j-1]]=max(dp[j-1][i]+1,dp[j][i+sq[j-1]]);

        }
    }
    //for(int i=0;i<20;i++)printf("%d ",dp[92][i]);
    if(dp[92][n]==0)dp[92][n]-=1;
    printf("%d\n",dp[92][n]);

}
0