結果

問題 No.385 カップ麺生活
ユーザー kosakkunkosakkun
提出日時 2016-12-06 17:20:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,084 bytes
コンパイル時間 995 ms
コンパイル使用メモリ 98,216 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-28 03:09:06
合計ジャッジ時間 2,025 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 31 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
ll dp[10010];
bool isPrime(long long n){
if(n<=1)return false;
if(n==2)return true;
for(long long i=2;i*i<=n;i++){
if((n%i)==0)return false;
}
return true;
}
int main(){
ll M,N; cin>>M>>N;
vector<ll> C(N);
REP(i,N)cin>>C[i];
REP(i,N){
dp[C[i]]=1;
for(ll j=0;j<10010;j++){
if(j-C[i]>=0){
if(dp[j-C[i]]>0)dp[j]=max(dp[j-C[i]]+1,dp[j]);
}
}
}
ll ans=0;
for(ll i=0;i<=M;i++){
if(isPrime(M-i)){
ans+=dp[i];
}
}
/*REP(i,101){
if(dp[i]>0){
cout<<i<<":"<<dp[i]<<endl;
}
}*/
sort(C.begin(),C.end());
ans+=M/C[0];
cout<<ans<<endl;
return 0;
}
/*
int main(){
int H,W; cin>>H>>W;
vector<string> S(H);
REP(i,H)cin>>S[i];
double ax=-1,ay=-1;
double bx=-1,by=-1;
REP(i,H)REP(j,W){
if(S[i][j]=='*'){
ax=j;
ay=i;
S[i][j]='-';
goto next1;
}
}
next1:;
REP(i,H)REP(j,W){
if(S[i][j]=='*'){
bx=j;
by=i;
goto next2;
}
}
next2:;
REP(i,H)REP(j,W){
double cx=j,cy=i;
}
return 0;
}
*/
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0