HDU-1701-ACMer

Source: Internet
Author: User

Question Link

Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1701

Solution:

I haven't done questions for a long time, I haven't written my ideas about solving problems, I won't even do short answer questions, and the monthly round in the afternoon is suspended. I am miserable and I am complaining here. O (zookeeper) O alas

A good short answer is actually wa, a float trap, more than once. At first, I couldn't understand the question. The number of acmers is between P % and Q %, so P % and Q % cannot be the same, because one is at least and the other is at most. Check the Code:

[CPP]View plaincopy
  1. # Include <iostream>
  2. Using namespace STD;
  3. Int main ()
  4. {
  5. Int T, I; Double A, B;
  6. Cin> T;
  7. While (t --)
  8. {
  9. Cin> A> B;
  10. For (I = 1; I ++)
  11. {
  12. If (INT) (A * I/100) <(INT) (B * I/100 ))
  13. Break;
  14. }
  15. Cout <I <Endl;
  16. }
  17. Return 0;
  18. }

 

Pay special attention to the floating point type. The following situations often occur.







Wa

# Include <stdio. h> int main (void) {double p, q; double I, K; int N; while (scanf ("% d", & n) = 1) {While (n --) {k = 1.0; scanf ("% lf", & P, & Q); for (I = 1; I ++) {P = P/100; q = Q/100; If (INT) (I * P) <(INT) (I * q) {printf ("%. LF \ n ", I); break ;}}} return 0 ;}

AC
# Include <stdio. h> int main (void) {double p, q; double I, K; int N; while (scanf ("% d", & n) = 1) {While (n --) {k = 1.0; scanf ("% lf", & P, & Q); for (I = 1; I ++) {If (INT) (I * P/100) <(INT) (I * q/100) {printf ("%. LF \ n ", I); break ;}}} return 0 ;}

HDU-1701-ACMer

Related Keywords:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.