题意:两年一度的欧洲杯又开始了,小海可是一个铁杆球迷,每天晚上都会到XX酒吧观看激烈的比赛,而且小海有给小费的习惯,但是他给小费是由原则的:
1. 最终消费的总额必须是5的倍数;
2. 小费必须占最终支付总费用的5%~10%之间(包括边界)
假设小海在酒吧的消费是A元,小海带了B元来酒吧,小海想知道他有多少种支付方案供选择。
总费用 = 消费 + 小费
思路:直接遍历符合条件就+1。
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main(){
long long a,b;
while(cin>>a>>b){
int cnt=0;
for(long long i=a;i<=b;i++){
if(i%5!=0)
continue;
else{
long long c=i-a;
if(c*1.0/i<=0.1&&c*1.0/i>=0.05)
cnt++;
}
}
cout<<cnt<<endl;
}
return 0;
}