Bestcoder Round #51 (Div.2) A

Source: Internet
Author: User

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
2

0

#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

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.