Skip to content

Instantly share code, notes, and snippets.

@Sd-Invol
Created September 27, 2014 11:32
Show Gist options
  • Save Sd-Invol/d077807a011da8fee811 to your computer and use it in GitHub Desktop.
Save Sd-Invol/d077807a011da8fee811 to your computer and use it in GitHub Desktop.
#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