/** 题目:Trailing Zeroes (III) 链接:https://vjudge.net/contest/154246#problem/N 题意:假设n!后面有x个0.现在要求的是,给定x,要求最小的n; 思路:判断一个n!后面有多少个0,通过n/5+n/25+n/125+... */ #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; const int maxn = 5*1e8+1; int num(int m) { int cnt = 0; while(m>0){ cnt += m/5; m /= 5; } return cnt; } int main() { int T, cas=1, q; cin>>T; while(T--) { scanf("%d",&q); int lo = 5, hi = maxn; int m; int mis = maxn; while(lo<=hi){ m = (lo+hi)/2; int t = num(m); if(t>=q){ if(t==q) mis = min(mis,m); hi = m-1; }else { lo = m+1; } } if(mis==maxn) printf("Case %d: impossible ",cas++); else printf("Case %d: %d ",cas++,mis); } return 0; }