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]