[BOJ] 2293 동전 1

Time Lapse :NONE

2293.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <memory.h>

using namespace std;

#define MAXSIZE 101
#define devide 1000000000
int arr[10001]={0,};
int money[100];
int n,k;
int ans=0;


int main(void)
{
cin>>n>>k;
memset(arr,0,sizeof(arr));
for(int i=0;i<n;i++)
cin>>money[i];

arr[0]=1;

for(int i=0;i<n;i++)
{
for(int j=money[i];j<=k;j++)
{
arr[j]+=arr[j-money[i]];
}
}
cout<<arr[k]<<endl;

}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/BOJ/2293/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.