Bc-zball in Tina town (prime number + law)

Source: Internet
Author: User

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)

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.