Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 1764 | Accepted: 802 |
Description
Computer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the form
Input
Each line of input will contain a pair of integers for STEP and MOD in that order (1<=STEP,MOD<=100000).
Output
For each line of input, your program should print the STEP value right-justified in columns 1 through 10, the MOD value right-justified in columns 11 through 20 and either "Good Choice" or "Bad Choice" left-justified starting in column 25. The "Good Choice" message should be printed when the selection of STEP and MOD will generate all the numbers between and including 0 and MOD-1 when MOD numbers are generated. Otherwise, your program should print the message "Bad Choice". After each output test set, your program should print exactly one blank line.
Sample Input
Sample Output
Source
South Central USA 1996
*********************************************************************
*********************************************************************
Source Code
Problem: 1597 | User: xcl119xcl | |
Memory: 72K | Time: 0MS | |
Language: C++ | Result: Accepted |
#include<stdio.h> int main() { long stp,mod,n; while(scanf("%ld%ld",&stp,&mod)!=-1){ printf("%10ld%10ld ",stp,mod); n=stp>mod?mod:stp; for(;n>1;n--) if(stp%n==0&&mod%n==0) break;//判断stp和mod是否互素 if(n==1) printf("Good Choice/n/n"); else printf("Bad Choice/n/n"); } return 0; }
3 5 Good Choice 15 20 Bad Choice 63923 99999 Good Choice
3 5 15 20 63923 99999
seed(x+1) = [ seed(x) + STEP ] % MOD
where "%" is the modulus operator.