Codevs 2632 very good friends

Source: Internet
Author: User

Title Description Description

Bessie and all the other cows have a radio frequency identification (RFID) serial number tag on their ears. So the farmer John can calculate their number mechanically. Many cows have a "Nou You". If the sum of the serial numbers of cow A is exactly equal to the serial number of cow B, then the Nou You of A is B. Here, a number's "approximate" does not include the number itself.

Because some cows are numbered and larger than any other cow's number, these cows are not Nou You. And some cows have a "very good friend", when two cows each other "Nou You", they are a pair of "very good friends." Note In this question, ignore those who are their own "very good friends" situation.

Given a serial number S (6≤s≤18,000), locate the first cow with a "very good friend" with a serial number not less than S.

For example, consider the serial number 220, which is approximate 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, and 110, and 284. Similarly, 284 of the approximate is 1, 2, 4, 71, and 142, their and is 220. So 220 and 284 are a pair of very good friends.

Enter a description Input Description

Line 1th: A separate integer s, which is the given sequence number.

Output description Output Description

Line 1th: 2 integers A and b, separated by a space. A indicates the serial number of a cow with a very good friend whose first serial number is not less than S, and B is the serial number of his "very good friend".

Sample input Sample Input

206

Sample output Sample Output

220 284

Code:
#include <cstdio>//a water problemusing namespacestd;intN;intFintx) {    intans=0;  for(intI=1; i<=x/2; i++)      if(x%i==0) ans+=i; returnans;}intMain () {inti; scanf ("%d",&N);  for(I=n;; i++)    {        intt=f (i); if(f (t) ==i&&t!=i) {printf ("%d%d", i,t); return 0;; }    }    return 0;}

Codevs 2632 very good friends

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.