啤酒和饮料 蓝桥杯

来源:互联网 发布:mysql count 两个字段 编辑:程序博客网 时间:2024/04/28 18:35

Description

啤酒每罐2.3元,饮料每罐1.9元。小明买了若干啤酒和饮料,一共花了s元。 我们还知道他买的啤酒比饮料的数量少,请你计算他买了几罐啤酒。

Input

输入数据有多组,每组占一行,包含小明买东西花的总钱数s。

Output

每行一组数据,输出小明买了多少罐啤酒。

Sample Input

82.3

Sample Output

#include<iostream>
using namespace std; 
int main() 
{ double s;
 while(cin>>s)
{
    for(int i = 1; i * 2.3 <= s; i++)  
        for(int j = i + 1; i * 2.3 + j * 1.9 <= s; j++)  
        {       
            if(i * 2.3 + j * 1.9 >= s - 0.000001 && i * 2.3 + j * 1.9 <=  s + 0.000001)     
                cout<<i<<endl;  
} }
        return 0;  
}
/**************************************************************
    Problem: 2505
    User: 201358505136
    Language: C++
    Result: Accepted
    Time:4 ms
    Memory:1268 kb
****************************************************************/
0 0
原创粉丝点击