Tle state-uva, 967 Circular

Source: Internet
Author: User

Test instructions: Give you an interval, ask if there is a number of prime change digits after still a prime example: 19937, 99371, 93719, 37199, 71993 q interval There are several

The ps:time_limit_exceeded! Maybe the circle function timed out, but I don't know what the problem is.

Train of thought: Print the prime list, cycle judgment can ...

( ̄ε (# ̄) ☆╰╮ ( ̄▽ ̄///)(you are still wrong to hair

( ̄ε (# ̄) (I also want to be right, beg a Ming road Qaq

Tle Code:

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5 using namespacestd;6 7 #defineMAXN 10000018 #definell9 //#define OnlinejudgeTen intcnt,counts; One LongL,r; A BOOLISPRIME[MAXN]; - LongPRIME[MAXN]; -  the BOOLdatecin () - { -counts=0; -scanf"%ld",&l); +     if(l==-1) -         return false; +scanf"%ld",&R); A     return true; at } -  - voidgetprime () - { -     inti,j; -memset (IsPrime,1,sizeof(IsPrime)); inisprime[0]=isprime[1]=cnt=0; -      for(i=2; i*i<maxn;i++) to     { +         if(Isprime[i]) -         { the              for(j=i*i;j<maxn;j+=i) *             { $                 if(Isprime[j])Panax Notoginseng                 { -isprime[j]=false; the                 } +             } A  the         } +     } -      for(i=2; i<maxn;i++) $     { $         if(Isprime[i]) -prime[cnt++]=i; -     } the } - Wuyi intGETW (Longnum) the { -     intI=0; Wu      while(num!=0) -     { AboutNum/=Ten; $i++; -     } -     returni; - } A  + BOOLCircleLongnum) the { -     intw=GETW (num); $     intg=1; the      for(intI=1; i<w;i++) g*=Ten; the      for(intI=1; i<w;i++) the     { thenum=num/Ten+ (num%Ten)*G; -         //cout<<num<<endl; in         if(!Isprime[num]) the             return false; the     } About     return true;; the } the  the voiddatecal () + { -      for(intI=0; i<cnt;i++) the     {Bayi         if(prime[i]>R) the              Break; the         if(prime[i]>=l&&prime[i]<=R) -         { -             if(Circle (Prime[i])) thecounts++; the         } the     } the } -  the voidshowres () the { the     if(counts==0)94printf"No Circular primes.\n"); the     Else if(counts==1) theprintf"1 Circular prime.\n"); the     Else if(counts>1)98printf"%d Circular primes.\n", counts); About } - 101 102 intMain ()103 {104  the getprime ();106 #ifdef LL107      while(Datecin ())108     {109 datecal (); the #ifdef Onlinejudge111Freopen ("D:\\uva_967.txt","W", stdout); the         #endif //Onlinejudge113 showres (); the  the     } the     #endif //ll117     return 0;118}

=s= Well, the current state of tle, put this up first, I do the other ( ̄ε (# ̄) ☆╰╮ ( ̄▽ ̄///) (Your learning soul?

Tle state-uva, 967 Circular

Related Article

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.