博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
啤酒和饮料 蓝桥杯
阅读量:4509 次
发布时间:2019-06-08

本文共 725 字,大约阅读时间需要 2 分钟。

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
****************************************************************/

转载于:https://www.cnblogs.com/oversea201405/p/3767008.html

你可能感兴趣的文章
华为ensp工具栏丢失解决方法
查看>>
静态网页中的使得文字向上一直滚动,中间不间断。
查看>>
MySQL常见错误代码说明
查看>>
innobackupex 相关语法讲解【转】
查看>>
pt-table-sync同步报错Called not_in_left in state 0 at /usr/bin/pt-table-sync line 5231【原创】...
查看>>
jooq使用示例
查看>>
属性参数
查看>>
AQS独占式同步队列入队与出队
查看>>
修改原代码定制bootstrap
查看>>
idea快捷键
查看>>
shell——bash在线编辑
查看>>
Kth Smallest Element in a BST
查看>>
iOS开发从新手到App Store上架
查看>>
poj--2516--Minimum Cost(最小费用流)
查看>>
ZXV10 H608B V1.1.04T02_JS破解
查看>>
数据可视化是什么
查看>>
强连通分量
查看>>
WinForm应用程序之注册模块的设计与实现
查看>>
spark-Streaming
查看>>
UVa1252
查看>>