結果
問題 | No.458 異なる素数の和 |
ユーザー | ふっぴー |
提出日時 | 2017-05-09 10:15:27 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 956 bytes |
コンパイル時間 | 2,124 ms |
コンパイル使用メモリ | 168,540 KB |
実行使用メモリ | 4,480 KB |
最終ジャッジ日時 | 2023-10-12 21:41:55 |
合計ジャッジ時間 | 6,835 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 2 ms
4,352 KB |
testcase_13 | AC | 2 ms
4,348 KB |
testcase_14 | RE | - |
testcase_15 | AC | 2 ms
4,352 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | AC | 2 ms
4,348 KB |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define loop(i,a,b) for(i=a;i<b;i++) #define rloop(i,a,b) for(i=a;i>=b;i--) #define vi vector<int> #define vl vector<ll> #define vii vector< vector<int> > #define vll vector< vector<ll> > #define vs vector<string> const int inf=1000000001; const ll INF=1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 int main(){ int n,i,j; cin>>n; vi sosuu; vi moto(n+1); loop(i,0,n+1){ moto[i]=i; } moto[0]=moto[1]=-1; loop(i,2,n+1){ if(moto[i]!=-1){ bool flag=false; loop(j,2,sqrt(i+1)){ if(i%j==0){ flag=true; break; } } if(flag==false){ sosuu.push_back(i); loop(j,1,n/i+1){ moto[i*j]=-1; } } } } vector<int> dp(n+1,-1); dp[0]=0; loop(i,0,sosuu.size()+1){ rloop(j,n-i,0){ if(dp[j]!=-1){ dp[j+sosuu[i]]=max(dp[j+sosuu[i]],dp[j]+1); } } } cout<<dp[n]<<endl; }