Zball in Tina townaccepts:397submissions:2463Time limit:3000/1500 MS (java/others)Memory limit:262144/262144 K (java/others) 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 gets bigger. 1 Times. On the second day, it gets bigger. 2 Times. In section nnn Days, it gets bigger. nnn Times. Zball the original volume is 1 。 Tina would like to know that Zball in the first n?1n-1 n? 1 The volume of the day nnn How big is the modulus? 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 TTT That represents the number of data groups next TTT Rows, one positive integer per line nnn , the meaning of the title surface is describedt≤105,2≤n≤109t \leq 10^5,2 \leq n \leq 10^9T≤1 0? 5 ??,2≤N≤1 0? 9 ??
Output description
For each set of data, output a positive integer that represents the answer.
Input sample
2310
Output sample
20
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #define LL Long Longusing namespace Std; ll N,m;bool Su (ll N) {for (int i=2;i*i<=n;i++) { if (n%i==0) return false; } return true;} int main () { LL y,x,k,t,s,l,r; LL CLA; scanf ("%lld", &CLA); while (cla--) { scanf ("%lld", &n); if (n==4) printf ("2\n"); else if (SU (n))//Wilson theorem { printf ("%lld\n", n-1); } else printf ("0\n"); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Bestcoder Round #51 (Div.2) A