結果

問題 No.385 カップ麺生活
ユーザー kosakkunkosakkun
提出日時 2016-12-06 17:20:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,084 bytes
コンパイル時間 793 ms
コンパイル使用メモリ 95,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 19:33:38
合計ジャッジ時間 2,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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;
}
*/
0