Because the exchange of several wrong .... And the pit point is num1 can be greater than num2

Source: Internet
Author: User

Finish number

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 22289 Accepted Submission (s): 8150


Problem description Definition: If a positive integer greater than 1 equals the sum of all the factors equal to its own, then the number is said to be the number, such as 6, 28 is the completion of the number: 6=1+2+3;28=1+2+4+7+14.

The task is to determine the number of two positive integers.

Input data contains multiple lines, the first line is a positive integer n, which indicates the number of test instances, then n test instances, each of which consists of two positive integers num1 and num2, (1<num1,num2<10000).

Output for each set of test data, print out the number of NUM1 and num2 (including NUM1 and num2) that exist.

Sample Input22 55 7

Sample Output01
1#include <iostream>2#include <cstdio>3 using namespacestd;4 int_is (intx)5 {6     inti,j,k,l,sum=1;7      for(i=2; i<=x/2; i++)8     {9         if(x%i==0)Ten         { Onesum+=i; A         } -     } -     if(sum==x) the         return 1; -     return 0; - } - intMain () + { -     intX,y,i,j,n; +Cin>>N; A      while(n--) at     { -         intCount=0; -scanf"%d%d",&x,&y); -         if(x>y) -         { -             intT; int=x; -x=y; toy=T; +         } -          for(i=x;i<=y;i++) the         { *             if(_is (i)) $             {Panax Notoginsengcount++; -             } the         } +printf"%d\n", count); A     } the      +}

Because the exchange of several wrong .... And the pit point is num1 can be greater than num2

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.