You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For example, 5! = 120, 120 contains one zero on the trail.

Input

Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case contains an integer Q (1 ≤ Q ≤ 108) in a line.

Output

For each case, print the case number and N. If no solution is found then print 'impossible'.

Sample Input

3

1

2

5

Sample Output

Case 1: 5

Case 2: 10

Case 3: impossible

AC代码

 #include<stdio.h>
const int MAXN=0x3f3f3f3f;//这个要足够大才能找到10^8
int getq(int x){
int q=;
while(x){
q+=x/;
x/=;
}
return q;
}
void erfen(int n){
int l=,r=MAXN;
while(l<=r){
int mid=(l+r)>>;
if(getq(mid)>=n)r=mid-;//二分这点注意
else l=mid+;
}
if(getq(l)==n)printf("%d\n",l);
else puts("impossible");
}
int main(){
int T,Q,flot=;
scanf("%d",&T);
while(T--){
scanf("%d",&Q);
printf("Case %d: ",++flot);
erfen(Q);
}
return ;
}

最新文章

  1. Android混淆代码
  2. 你写的return null正确吗?
  3. 浅析for in 和for的区别
  4. JQuery测手速小游戏-遁地龙卷风
  5. arcgis server 10.2安装后,忘记Manager的用户名和密码
  6. Android 脚本替换PackageName
  7. CSAPP缓冲区溢出攻击实验(上)
  8. 手写归并排序(MergeSort)
  9. Object-C中emoji与json的问题
  10. mysql pdo数据库连接
  11. 小甲鱼python基础教程飞机大战源码及素材
  12. Java网络编程(二)关于Socket的一些个人想法
  13. AppDomain.CurrentDomain.BaseDirectory是什么
  14. 二维数组sort排序
  15. [CALayer release]: message sent to deallocated instance iOS内存过度释放问题
  16. Python 学习笔记之random 模块
  17. response提交原理(转)
  18. codeforces 359E Neatness(DFS+构造)
  19. Linux驱动虚拟地址和物理地址的映射
  20. sql数据库发布、订阅同步方式操作

热门文章

  1. 双系统重装win7和ubuntu修复win7引导方法介绍(来源百度经验)
  2. C++(二)— STL容器的基本用法
  3. linux应用之yum命令的软件源的更换(centos)
  4. Idea_学习_03_IDEA中使自定义类型的文件进行代码高亮识别
  5. PHP把时间转换成几分钟前、几小时前、几天前的几个函数、类分享
  6. 7_DoubleBuffer 游戏编程中的双缓存模式
  7. Python 爬虫 —— 文件及文件夹操作
  8. ACM学习历程—HDU4675 GCD of Sequence(莫比乌斯)
  9. 一步一步学RenderMonkey
  10. http头部解释