We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int ceil(int a, int b){
a+= (a%b) ?b-a%b :0;
return a/b;
}
int main() {
int t;
cin>>t;
vector<int> numbers{5,10,20,50,100,200};
int n=pow(10,5);
long long answers[n+1];
for (int i=0; i<n+1; i++){
answers[i]=ceil(i+1,2);
}
for (int i: numbers){
for (int j=i; j<n+1; j++){
answers[j]+=answers[j-i];
answers[j]%=modulo;
}
}
while (t--){
cin>>n;
cout<<answers[n]<<endl;
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #31: Coin sums
You are viewing a single comment's thread. Return to all comments →
Cpp code C++20
include
include
include
include
include
using namespace std;
long long modulo=pow(10,9)+7;
int ceil(int a, int b){ a+= (a%b) ?b-a%b :0;
return a/b; } int main() { int t; cin>>t;
}