Hdoj Topic 2303 The embarrassed cryptographer (mathematics)

Source: Internet
Author: User

The embarrassed cryptographerTime limit:3000/2000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 563 Accepted Submission (s): 172


Problem DescriptionThe Young and very promising cryptographer ODD even have implemented the security module of a large Syst Em with thousands of the users, which is now-in The cryptographic keys are created from the product of both primes, and are believed to being secure because there is no known Method for factoring such a product effectively.
What ODD even does not think of, is, both factors in a key should is large, not just their product. It's now possible that some of the users of the system has weak keys. In a desperate attempt is fired, Odd even secretly goes through all the users keys, to check if they is strong ENO Ugh. He uses his very poweful Atari, and was especially careful when checking his boss ' key.
Inputthe input consists of no more than test cases. Each test case was a line with the integers 4 <= K <= 10100 and 2 <= L <= 106. K is the key itself, a product of the primes. L is the wanted minimum size of the factors in the key. The input set is terminated by a case where K = 0 and L = 0.
Outputfor each number K, if one of its factors is strictly less than the required L, your program should output "bad P", where p is the smallest factor in K. Otherwise, it should output "good". Cases should is separated by a line-break.
Sample Input
143 10143 20667 20667 302573 302573 400 0

Sample Output
Goodbad 11GOODBAD 23GOODBAD 31

SourceNCPC2005
Recommendzty | We have carefully selected several similar problems for you:2300 2308 2301 2305 2306 Enter a large number and an integer k, and then see if that large number can be divisible by one prime, if Can see that the prime number is larger or smaller than k, if the small output bad, and the prime number output, otherwise the output GOODAC code
#include <stdio.h> #include <string.h>int is[1000010],prim[10000100],num=0,k;void fun () {int i,j;for (i=2; i<1000010;i++) {if (!is[i]) {prim[num++]=i;for (j=i+i;j<1000010;j+=i) {is[j]=1;}}}} Char S[220];int main () {fun (), while (scanf ("%s%d", s,&k)!=eof) {if (strcmp (S, "0") ==0&&k==0) Break;int len= Strlen (s), I,j,sum;for (i=0;i<num;i++) {int sum=0;for (j=0;j<len;j++) {sum= (sum*10+s[j]-' 0 ')%prim[i];} if (sum==0) break;} if (i!=num&&prim[i]<k) {printf ("Bad%d\n", Prim[i]);} elseprintf ("good\n");}}


Hdoj Topic 2303 The embarrassed cryptographer (mathematics)

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.