Problem description
Tina town is a kind and friendly place where everyone cares about each other.
Tina has a ball whose name is Zball. Zball is amazing, it gets bigger every day. On the first day, it will be 11 times times bigger. On the second day, it will be 22 times times bigger. On the first NN day, it will become larger than the NN.
The original volume of Zball is 11. Tina would like to know how big the volume of Zball in the first n-1n?1 of the NN?
Tina is a stupid girl, of course not, so she asked you to help her figure out the answer.
Enter a description
First line a positive integer TT, representing the number of data groups
Next TT line, each line of a positive integer nn, meaning title surface described
T \leq 10^5,2 \leq n \leq 10^9t≤10
? 5
?? , 2≤n≤10
? 9
Output description
For each set of data, output a positive integer that represents the answer.
Input sample
2
3
10
Output sample
2
0??
This competition, can only say that the person you happy is good.
First we can first 10, we will find a rule, if n is the prime number of output n-1, if it is not a prime output 0, and when n=4, the result is 2 need a special sentence.
The problem may be that the data is too watery to see others using the most brutal method of judging primes: O (T*SQRT (n)) can also be too.
The code is as follows:
#include <iostream>#include <stdio.h>#include <queue>#include <stack>#include <algorithm>#include <string.h>#include <string>#include <math.h>using namespace STD;BOOLIsPrime (intNUM) {if(num = =2|| num = =3) {return true; }if(num%6!=1&& num%6!=5) {return false; } for(inti =5; I*i <= num; i + =6) {if(num% i = =0|| Num% (i+2) ==0) {return false; } }return true;}intMain () {intTscanf("%d", &t); while(t--) {intNscanf("%d", &n);if(n==4)printf("2\n");Else if(IsPrime (n))printf("%d\n", N-1);Else if(!isprime (n))printf("0\n"); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Bestcoder Round #51 (Div.2) Zball in Tina town