Light Oj 1138 Trailing Zeroes (III) solution
Solution in C++:
///******Bismillahir-Rahmanir-Rahim******///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include<bits/stdc++.h>
using namespace std;
int five(int n)
{
int sz=0;
while(n)
{
sz+=n/5;
n/=5;
}
return sz;
}
int main()
{
int t,i;
cin>>t;
for(i=1; i<=t; i++)
{
int l=0,r=1000000000,v;
cin>>v;
while(l<=r)
{
int mid=l+(r-l)/2;
if(five(mid)>=v)
r=mid-1;
else
l=mid+1;
}
if(five(l)==v)
printf("Case %d: %d\n", i, l);
else
printf("Case %d: impossible\n", i);
}
}
https://lightoj.com/problem/crossed-ladders
ReplyDeleteata solve kore de