http://acm.hdu.edu.cn/showproblem.php?pid=1014
没事做,刷一些水题或基础题:
#include <iostream> #include <cstdio> #include <cstdlib> #define DM 10 using namespace std; int Step = 0, Mod = 0; /*intialize the var*/ int InitVar() { return 0; } /*get the number of bit for the num*/ int GetBit(int num) { int cnt = 0; while(num > 0) {
cnt++;
num /= 10; } return cnt; } /*GCD*/ int GCD(int a, int b) { int r = 0, temp = 0; if(a < b) {
temp = a;
a = b;
b = temp; } while((r = a%b) != 0) {
a = b;
b = r; } return b; } /*main process*/ void MainProc() { while(~scanf("%d %d", &Step, &Mod)) {
InitVar(); int Snum = GetBit(Step); int Mnum = GetBit(Mod); for(int i=1; i<=DM-Snum; i++) {
printf(" "); }
printf("%d", Step); for(int i=1; i<=DM-Mnum; i++) {
printf(" "); }
printf("%d", Mod);
printf(" "); if(GCD(Step, Mod) == 1) {
printf("Good Choice\n\n"); }else {
printf("Bad Choice\n\n"); } } } int main() {
MainProc(); return 0; }