题目来源于CCFCSP
代码解析
数据拆分成30与50的组合即可
代码解析
#include<iostream>
using namespace std;
int main()
{
int N,num = 0;
cin >> N;
for(int x = 0;x <= N;x += 10){
int y = N - x;
int three = x / 30;
int three_mod = (x % 30)/ 10;
int five = y / 50;
int five_mod = (y % 50)/10;
int value = three + 3 * three + three_mod + five * 2 + five * 5 + five_mod;
if(num < value)
num = value;
}
cout << num << endl;
return 0;
}
测试结果