UV problem solution: 10110-light, more light

Source: Internet
Author: User

The final state of the last bulb is determined by the number of factors of N. only the number which is the square of a number has an odd number of factors, thus it has a state of "yes ".

Code:

  1. /*************************************** ************************************
  2. * Copyright (c) 2008 by Liu kaipeng *
  3. * Liukaipeng at gmail dot com *
  4. **************************************** ***********************************/
  5. /* @ Judge_id 00000 10110 C ++ "light, more light "*/
  6. # Include <algorithm>
  7. # Include <cmath>
  8. # Include <cstdio>
  9. # Include <cstring>
  10. # Include <deque>
  11. # Include <fstream>
  12. # Include <iostream>
  13. # Include <list>
  14. # Include <map>
  15. # Include <queue>
  16. # Include <set>
  17. # Include <stack>
  18. # Include <string>
  19. # Include <vector>
  20. Using namespace STD;
  21. Int main (INT argc, char * argv [])
  22. {
  23. # Ifndef online_judge
  24. Freopen (string (argv [0]) + ". In"). c_str (), "r", stdin );
  25. Freopen (string (argv [0]) + ". Out"). c_str (), "W", stdout );
  26. # Endif
  27. /* The final state of the last bulb is determined by the number of factors
  28. Of N. Only the number which is the square of a number has odd number
  29. Factors, thus it has a state of "yes ".*/
  30. For (unsigned int N; CIN >>n & n! = 0 ;){
  31. Unsigned int r = SQRT (N );
  32. If (R * r = N) cout <"Yes/N ";
  33. Else cout <"No/N ";
  34. }
  35. Return 0;
  36. }

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.