Created
September 27, 2014 11:32
-
-
Save Sd-Invol/d077807a011da8fee811 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <cstring> | |
#include <cmath> | |
#include <algorithm> | |
#include <stack> | |
#include <queue> | |
#include <string> | |
#include <vector> | |
#include <set> | |
#include <map> | |
#include <cassert> | |
#include <cctype> | |
using namespace std; | |
typedef long long LL; | |
const int N = 105; | |
int n , b , q , ca; | |
void work() { | |
printf("Case #%d: " , ++ ca); | |
scanf("%d%d%d",&n,&b,&q); | |
if (q != 1 && q != 10 && q != 100 && q != 1000) { | |
printf("%.5f\n" , log10(1 + 1.0 / n)); | |
} else { | |
char s[10] , t[10]; | |
sprintf(s , "%d" , n); | |
if (q == 1) | |
sprintf(t , "%d" , b); | |
else | |
sprintf(t , "%d" , b * 100000); | |
int i; | |
for (i = 0 ; s[i] ; ++ i) | |
if (s[i] != t[i]) | |
break; | |
if (!s[i]) | |
puts("1.00000"); | |
else | |
puts("0.00000"); | |
} | |
} | |
int main() { | |
int _; scanf("%d",&_); while (_ --) | |
work(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment