Nyoj154 smart Xiaoke [Mutual quality]

Source: Internet
Author: User

Intelligent cool time limit: 1000 MS | memory limit: 1000 kb difficulty: 3
Description

Xiao Ke is a girl who loves beauty. She has n New necklaces ranging from 1 to n. Each necklace has some differences in color. N necklaces are placed in sequence and placed in a circle. Xiao Ke will count to the K necklace from the last time he selected the necklace, and use this necklace as the necklace to be brought today. The direction is the same every time, now, I hope you can help Xiao Ke calculate the largest K to meet K <= n/2 at the same time, so that Xiao Ke will carry all the necklaces in the next n days.

For example, n = 7, K = 3

Days necklace No.

1 1

2 4

3 7

4 3

5 6

6 2

7 5

Input
The first line has an integer 0 <m <10000 indicates that there are M groups of test data, and the next m row has an integer in each line, indicating the number of Xiao Ke's necklaces 2 <= m <2 ^ 31
Output
Output M k values
Sample Input
227
Sample output
13
Source
[Iphxer] original
Uploaded
Iphxer
Maximum m of the output and N mutual quality meeting conditions

#include <stdio.h>int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}int main() {int t, n, m;scanf("%d", &t);while(t--) {scanf("%d", &n);for(m = n / 2; m > 1; --m)if(gcd(m, n) == 1) break;printf("%d\n", m);}return 0;}


Nyoj154 smart Xiaoke [Mutual quality]

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.