-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem31.cpp
More file actions
41 lines (38 loc) · 797 Bytes
/
Problem31.cpp
File metadata and controls
41 lines (38 loc) · 797 Bytes
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
39
40
41
//73682
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void coins(int arr[],int sum,ll &ans,int k)
{
//cout<<sum<<"\n";
if(sum>200)
return;
if(sum==200)
{
ans++;
cout<<ans<<"\n";
return;
}
for(int i=k;i<8;i++)
{
//cout<<sum<<"\n";
if(sum+arr[i]<=200)
coins(arr,sum+arr[i],ans,i);
else
return;
}
return;
}
int main()
{
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int arr[] = {1,2,5,10,20,50,100,200};
ll ans = 0;
coins(arr,0,ans,0);
cout<<"\n"<<ans<<"\n";
}