Zoj 3758 singles 'day

Source: Internet
Author: User

Http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemid = 5203

Question: There are n numbers of 1 and then convert them to a 10-digit number according to the B-digit number to determine whether the number is a prime number.

 1 #include <cstdio> 2 #include <cstring> 3 #define LL unsigned long long 4 using namespace std; 5  6 int b,n; 7 bool deal(LL n) 8 { 9     if(n==1) return false;10     for(LL i=2; i*i<=n; i++)11     {12         if(n%i==0)13         {14             return false;15         }16     }17     return true;18 }19 20 int main()21 {22     while(scanf("%d%d",&b,&n)!=EOF)23     {24         LL ans=1;25         for(int i=0; i<n; i++)26         {27             ans*=b;28         }29         ans=(ans-1)/(b-1);30         if(deal(ans)) printf("YES\n");31         else printf("NO\n");32     }33     return 0;34 }
View code

 

Zoj 3758 singles 'day

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.