#include<bits/stdc++.h>
using namespace std;
long long calculate(long long a)
{
long long len,st[100],l=1,n=a;
while(1)
{
if(a < 10)
{
st[l++] = a;
break;
}
st[l++] = a%10;
a /= 10;
}
long long res = 0;
for(int i=1; i<l; i++)
{
if(i==1 || st[i] != 0)
{
res += pow(10,i-1) * floor(n/pow(10,i));
}
else
{
res += (pow(10,i-1) * (floor(n/pow(10,i))-1))+n+1-pow(10,i)*floor(n/pow(10.00,i));
}
}
return res;
}
int main()
{
long long T,i,k,m,n,l,result1,result2,c=1;
cin >> T;
while(T--)
{
cin >> m >> n;
result1 = calculate(m-1);
result2 = calculate(n);
cout << "Case " << c++ << ": " << result2-result1 << endl;
}
return 0;
}
Thursday, July 30, 2015
1140 - How Many Zeroes?
Subscribe to:
Post Comments (Atom)
Triathlon
Triathlon - CodeChef # include < bits/stdc++.h > using namespace std ; # define fi first # define se second # define mp ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , c = 1 ; double r1 , r2 , h , p ; // ...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { long long T , S , l , n , c = 1 ; // freopen(&qu...
-
# include < bits/stdc++.h > using namespace std ; int main ( ) { int T , n , p , q , c = 1 , i , w , t , arry [ 50 ] ; ...
No comments:
Post a Comment