URAL 1011 Conductors
[报告]
数学问题……(不过我不知道我以前的程序为什么错)
先将P,Q从百分数换成小数,然后枚举汽车的数量,直到区间[I/Q,I/P]之间有正整数(这个判断影响程序的正确性和效率),答案就是I/Q,I/P]之间最小正整数。
[程序]
#include <cstdlib>
#include <iostream>
#include <cmath>
#define d 1e-6
using namespace std;
int main(int argc, char *argv[])
{
double
p,q;
cin
>> p >>
q;
p=p/100;q=q/100;
for (long
i=1;true;i++)
{
double x=i/p,y=i/q;
// cout << x
<< " "
<< y <<
endl;
if (long(y+d)+1<=long(x-d))
{
cout << long(y+d)+1
<< endl;
break;
}
//
cin.get();
}
// system("PAUSE");
return
EXIT_SUCCESS;
}
为什么来到这,行将终结、匆忙纷扰、并且完全看不到救赎的世界。

浙公网安备 33010602011771号