Posted on 2008-04-23 22:44
ZelluX 閱讀(815)
評論(10) 編輯 收藏 所屬分類:
Algorithm
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.
我只能說太挫了。。。精度問題搞了半天,看來浮點還是要盡量化成整型再算啊。


?1?#include?<iostream>
?2?#include?<cmath>
?3?
?4?using?namespace?std;
?5?
?6?int?main()
?7?{
?8?????double?dp,?dq;
?9?????cin?>>?dp?>>?dq;
10?????int?p?=?floor(dp?*?100?+?0.5);
11?????int?q?=?floor(dq?*?100?+?0.5);
12?????for?(int?i?=?1;?;?i++)?{
13?????????int?a?=?p?*?i?/?10000;
14?????????int?b?=?q?*?i?/?10000;
15?????????if?((a?<?b)?&&?(q?*?i?%?10000?>?0))?{
16?????????????cout?<<?i?<<?endl;
17?????????????return?0;
18?????????}
19?????}
20?????return?0;
21?}
22?還有個問題就是q*i是開區間還是閉區間,總之Wrong Answer了無數次后總算過了。。。