Zball in Tina townaccepts:541submissions: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. 11 Times. On the second day, it gets bigger. 22 Times. In section nn Days, it gets bigger. nn Times. Zball the original volume is 11 。 Tina would like to know that Zball in the first n-1 n? 1 The volume of the day nn 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 tt That represents the number of data groups next tt Rows, one positive integer per line nn , the meaning of the title surface is describedT \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
The problem is purely law-seeking
#include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <queue > #include <cmath>using namespace std;typedef long Long ll;int t,n;int fn (int x) { if (x = = 1) return 1; else if (x = = 4) return 2; for (int i = 2; I * i <= x; i + +) { if (x% i = = 0) return 0; } return x-1;} int main () { scanf ("%d", &t); while (T--) { scanf ("%d", &n); printf ("%d\n", FN (n)); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Bc-zball in Tina town (prime number + law)