Hdoj (HDU) 1406 finish

Source: Internet
Author: User

Problem Description
The definition of the end number: If a positive integer greater than 1 equals the sum of all the factors of its own, then it is said that the number is the end number, such as 6, 28 is the end number: 6=1+2+3;28=1+2+4+7+14.

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

Input
The input data contains multiple lines, the first line is a positive integer n, which indicates the number of test instances, then the N test instances, each one row, consisting of two positive integers num1 and num2, (1

Import Java.util.Scanner; Public classmain{ Public Static void Main(string[] args) {Scanner SC =NewScanner (System.inch);intt = Sc.nextint (); while(t-->0){intA = Sc.nextint ();intb = Sc.nextint ();if(A&GT;B)                {a=a^b;                B=a^b;            A=a^b; }intnum = Numm (A, b); System. out. println (num); }    }Private Static int Numm(intAintb) {intnum =0; for(inti=a;i<=b;i++) {if( is(i))            {num++; }        }returnNum }Private StaticBoolean is(intA) {intnum=1; for(intI=2; i*i<=a;i++) {if(a%i==0) {num=num+i;            num=num+a/i; }        }if(A==num) {//system.out.println (a);            return true; }return false; }}

Hdoj (HDU) 1406 finish

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.