二分
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define C 0.5772156649 #define pi acos(-1.0) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-7; const int N=100000+10,maxn=500+100,inf=0x3f3f3f; ll getzero(ll k) { ll ans=0; while(k){ ans+=k/5; k/=5; } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(0); ll t,cnt=0; cin>>t; while(t--){ ll n; cin>>n; ll l=1,r=500000000; while(l<=r){ ll m=(l+r)/2; if(getzero(m)<n)l=m+1; else r=m-1; } if(getzero(l)==n)cout<<"Case "<<++cnt<<": "<<l<<endl; else cout<<"Case "<<++cnt<<": impossible"<<endl; } return 0; } /********************* 100000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 *********************/
时间: 2024-11-06 05:34:42