Vijos P1785 Classmate Sort "simulation"

Source: Internet
Author: User

Classmate Sort Description

The existing M-students, the 1th students for 1th, 2nd Students for 2nd, in turn, the first M-student is M. Ask the students to stand out, and then the rest of the re-composition, after the combination, once again let the students stand up, repeat n times, how many students come out to stand?

Example 1 Sample Input 1
1989 5
Sample Output 1
1926
Limit

1s

Tips

"Data Range"
1≤n≤10
100≤m≤100000

Title Link: https://vijos.org/p/1785

Analysis: The number of people standing out is even, if the total number is odd, the rest of the population up to take the whole again binary is good!

The AC code is given below:

1#include <bits/stdc++.h>2 using namespacestd;3 intMain ()4 {5     intn,m;6Cin>>n>>m;7     intI=1, ans=0;8      while(i<=m)9     {Teni++; Oneans+=n/2; AN= (n+1)/2; -     } -cout<<ans<<Endl; the     return 0; -}

Vijos P1785 Classmate Sort "simulation"

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.