7649: house number of my house, 7649: house number

Source: Internet
Author: User

7649: house number of my house, 7649: house number
7649: house number of my house

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

My family lives in a short hutong. The street number of this hutong starts from 1.

If the sum of all the street numbers is twice the number of my house, it is equal to n.

The data guarantee has a unique solution.

Input
A positive integer n. N <100000.
Output
A row contains two positive integers, which are the house number and total number of houses in the house, separated by a single space.
Sample Input
100
Sample output
10 15
Source
Typical questions of Mathematical Olympiad (sixth grade primary school) (ISBN 978-7-5445-2883-2) Chapter 2 Lecture 7 EXAMPLE 2 expand 1
 1 #include<iostream> 2 using namespace std; 3 int now=1; 4 int tot=0; 5 int main() 6 { 7      8     int n; 9     int flag=0;10     cin>>n;11     while(1)12     {13         tot=tot+now;14         now++;15         int a;16         for(int i=1;i<=now;i++)17         {18             if(tot-i*2==n)19             {20                 cout<<i<<" "<<now-1;21                 flag=1;22                 break;23             }24         }25         if(flag==1)break;26     }27     return 0;28 }

 

Related Article

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.