結果

問題 No.458 異なる素数の和
ユーザー miwawamiwawa
提出日時 2024-02-17 13:58:57
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 32,256 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-17 13:59:03
合計ジャッジ時間 4,948 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
6,676 KB
testcase_01 AC 80 ms
6,676 KB
testcase_02 AC 82 ms
6,676 KB
testcase_03 AC 84 ms
6,676 KB
testcase_04 AC 82 ms
6,676 KB
testcase_05 AC 82 ms
6,676 KB
testcase_06 AC 84 ms
6,676 KB
testcase_07 AC 79 ms
6,676 KB
testcase_08 AC 82 ms
6,676 KB
testcase_09 AC 82 ms
6,676 KB
testcase_10 AC 83 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 82 ms
6,676 KB
testcase_13 AC 85 ms
6,676 KB
testcase_14 AC 84 ms
6,676 KB
testcase_15 AC 84 ms
6,676 KB
testcase_16 AC 83 ms
6,676 KB
testcase_17 AC 83 ms
6,676 KB
testcase_18 AC 83 ms
6,676 KB
testcase_19 AC 85 ms
6,676 KB
testcase_20 AC 81 ms
6,676 KB
testcase_21 AC 110 ms
6,676 KB
testcase_22 AC 81 ms
6,676 KB
testcase_23 AC 82 ms
6,676 KB
testcase_24 AC 85 ms
6,676 KB
testcase_25 AC 85 ms
6,676 KB
testcase_26 AC 84 ms
6,676 KB
testcase_27 AC 83 ms
6,676 KB
testcase_28 WA -
testcase_29 AC 84 ms
6,676 KB
testcase_30 AC 85 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define rep(i,a,b) for(i=a;i<b;i++)

int cha(const void*a,const void*b){
  if(*(int*)a >*(int*)b){
    return 1;
  }else if(*(int*)a <*(int*)b){
    return -1;
  }else{
    return 0;
  }
}


int main(void){
    int d,i,j,kk=0;
  int mini=1000,k=0,qi=0,qj=0,n;
  int s=0,h[100010];
  int a[20100],b[110],c[200],w=0;
int dp[2][20001];
  int heavy=1e9;
  long long aa,bb;
  scanf("%d",&n);
  rep(i,2,20000){
    s=0;
    rep(j,2,143){
      if(i%j==0){
        s++;
      }
    }
    if(s==1 && i<143){
      a[k]=i;
      k++;
    }else if(s==0){
      a[k]=i;
      k++;
    }
  }
  rep(i,0,20000){
    dp[0][i]=0;
  }
  dp[0][0]=0;
  j=0;
  rep(i,0,k){
    rep(j,0,20000){
      if(j-a[i]>=0){
      if(dp[0][j-a[i]]!=0){
    dp[1][j]=fmax(dp[0][j-a[i]]+1,dp[0][j]);
      }else if(j-a[i]==0){
        dp[1][j]=fmax(dp[0][j-a[i]]+1,dp[0][j]);
      }
      }
      }
    rep(j,0,20000){
      dp[0][j]=dp[1][j];
    }
  }
      if(dp[0][n]!=0){
    printf("%d\n",dp[0][n]);
      }else{
        printf("-1\n");
      }
}
0