首页 > 代码库 > 【HDOJ】3184 All Can Do

【HDOJ】3184 All Can Do

简单数学题。

 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4  5 int main() { 6     int t; 7     int T, b; 8     int i; 9     10 #ifndef ONLINE_JUDGE11     freopen("data.in", "r", stdin);12 #endif13     14     scanf("%d", &t);15     while (t--) {16         scanf("%d %d", &T, &b);17         if (90 % b) {18             printf("Impossible!\n");19         } else {20             if (T == 1) {21                 for (i=9; i>0; --i) {22                     if (i%b == 0)23                         break;24                 }25                 if (i == 0) {26                     printf("Impossible!\n");27                 } else {28                     printf("%d\n", i);29                 }30             } else {31                 for (i=99; i>9; --i) {32                     if (i%b == 0)33                         break;34                 }35                 while (T-- >= 3) {36                     printf("9");37                 }38                 printf("%d\n", i);39             }40         }41     }42     43     return 0;44 }

 

【HDOJ】3184 All Can Do