ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1011. Conductors

C++ program (严格按照题目来)
Posted by lz1 12 Jan 2012 17:49
// 严格按照题目来
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;

const int p = 10000;
double xs, ys;
int x, y, ans;

int main(void)
{
    scanf ("%lf%lf", &xs, &ys);
    ans = 1, x = y = 0;
    // 严格按照题目来 (more than ... ; less than ... )
    ys -= 1E-10, xs += 1E-10;
    while (x == y)
          ans++, x = int (ans * xs) / 100, y = int (ans * (ys)) / 100;
    printf ("%d", ans);
    return 0;
}
Re: C++ program (严格按照题目来)
Posted by kaa..........ai 21 Jun 2013 22:02
想知道为什么ys是减1E-10,而xs是加1E-10!
Re: C++ program (严格按照题目来)
Posted by kaa..........ai 21 Jun 2013 22:02
想知道为什么ys是减1E-10,而xs是加1E-10!
Re: C++ program (严格按照题目来)
Posted by asdvv 29 Jun 2014 21:12
because it said "more than P%" and "less than Q%", so it can't be equal, you have to shorten interval, just add or sub 1E-10
(因为题目是说“more than P%” 和 “less than Q%”,因此不能相等,所以两边的区间都要往里面再缩小一点,只要加或减1E-10就行)