- /****************##### بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم #####******************
- __________________________________________________________________________
- ###################### Ya-Seen Arafat(ACWizard) #########################
- ###################### UAP-CSE-33B #########################
- *************************************************************************/
- #include <bits/stdc++.h>
- #define ll long long
- #define S 1000003
- using namespace std;
- double cuS[S];
- void cumulativeSum(){
- cuS[1] = log((double)1);
- for(int i = 2; i < S; i++){
- cuS[i] = cuS[i-1] + log((double)i);
- }
- }
- int main(){
- int t, cs = 0, n, base;
- cumulativeSum();
- scanf("%d", &t);
- while(t--){
- scanf("%d %d", &n, &base);
- double value = cuS[n];
- value /= log((double)base);
- ll ans = value;
- ans += 1;
- printf("Case %d: %lld\n", ++cs, ans);
- }
- return 0;
- }
Sunday, February 28, 2016
LightOJ - 1045 - Digits of Factorial
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment