Hdu 5392 Zball in Tina town (prime)

Source: Internet
Author: User
Tags square root

Test instructions: (x-1)!modx (x<10^9), Goldbach conjecture, the table is suitable for the prime number of x, the result is x-1, composite when 0;X=4 is 2 Special award;

Thinking: When judging the prime number of the brain pumping, want to be a large numbers of primes, and then always tle;

When the square root of the number to be judged is the 10^8 level, consider the large number of cases ...

#include <cstdio>#include<cstring>#include<algorithm>using namespacestd;intt,n,m;intMain () {intI,j,k,flag; scanf ("%d",&t);  while(t--) {scanf ("%d",&N); if(n==4) {printf ("2\n");Continue; } Flag=0;  for(i=2; i*i<n;i++){        if(n%i==0) {flag=1; Break; }    }    if(flag) printf ("0\n"); Elseprintf"%d\n", N-1); }   return 0;}

Hdu 5392 Zball in Tina town (prime)

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.