|
|
вернуться в форумC++ program (严格按照题目来) Послано lz1 12 янв 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 (严格按照题目来) 想知道为什么ys是减1E-10,而xs是加1E-10! Re: C++ program (严格按照题目来) 想知道为什么ys是减1E-10,而xs是加1E-10! Re: C++ program (严格按照题目来) Послано asdvv 29 июн 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就行) |
|
|