UARL 1011

题目很简单:

给两个浮点数p, q做为输入,两个浮点数都是精确到小数位后面两位。

要求一个数x使得[x*p, x *q]中至少有一个整数出现。

当然输入13表示13%

http://acm.timus.ru/problem.aspx?space=1&num=1011

1011. Conductors

Time Limit: 2.0 second
Memory Limit: 16 MB

Background

Everyone making translations from English to Russian knows an English phrase "Naked conductor runs along the bus". It has two very different meanings.

Problem

Every bus in the Ekaterinburg city has a special man (or woman) called conductor. When you ride the bus, you have to give money to the conductor.We know that there are more then P% conductors and less then Q% conductors.Your task is to determine a minimal possible number of Ekaterinburg citizens.

Input

Two numbers P, Q such that 0.01 ≤ P, Q ≤ 99.99. Numbers are given with 2 digits precision. These numbers are separated by some spaces or "end of line" symbols.

Output

The minimal number of Ekaterinburg citizens.

Sample

inputoutput
13
14.1
15
Problem Source: USU Championship 1997


粘个代码吧。写得比较挫

#include<stdio.h>
#include<stdlib.h>

double p, q;
double from, to, x;
int pp, qq;
int main(void)
{
	while (scanf("%lf%lf", &p, &q) != EOF)
	{
		p *= 100.0; q *= 100.0; x = 1;
		while (1)
		{
			pp = (int)(p * x);
			qq = (int)(q * x);
			if(qq/10000-pp/10000>=1 && qq%10000 && pp % 10000) break;
			x = x + 1;
		}
		pp = x;
		printf("%d\n", pp);
	}
	return 0;
}

这个题实际上要考虑的东西还比较多。

1、两位小数,所以得乘上100

2、取整的话需要除10000.

我反正是错了N遍


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值