ZZ 国的货币系统包含面值 1 元、4 元、16 元、64 元共计四种硬币,以及面值 1024 元的纸币。
现在小 Y 使用 1024 元的纸币购买了一件价值为 N 的商品,请问最少他会收到多少硬币。
输入格式
共一行,包含整数 N。
输出格式
共一行,包含一个数,表示最少收到的硬币数。
数据范围
0<N≤1024
输入样例:
200
输出样例:
17
/*
* @Description: To iterate is human, to recurse divine.
* @Autor: Recursion
* @Date: 2022-04-11 14:05:21
* @LastEditTime: 2022-04-11 14:19:40
*/
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e9 + 10;
int N = 1024;
int a[] = {1, 4, 16, 64};
int n;
int ans;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
N = 1024 - n;
for(int i = 3;i >= 0;i --){
if(N >= a[i]){
ans += N/a[i];
N = N % a[i];
}
}
cout << ans << endl;
return 0;
}