-
-
Save MinecraftFuns/fbcd65f2e03dbbf34fc89b6488952942 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 <bits/stdc++.h> | |
#define alive std::cout << "$LINE @" << __LINE__ << " ALIVE" << std::endl | |
#define watch(var) std::cout << "$ LINE @" << __LINE__ << " FUN @" << __FUNCTION__ \ | |
<< " VAR @" << (#var) << ": " << (var) << std::endl | |
using namespace std; | |
typedef int i32; | |
typedef unsigned int u32; | |
typedef long long i64; | |
typedef unsigned long long u64; | |
typedef double f64; | |
typedef long double f128; | |
typedef pair<int, int> pii; | |
template <typename Tp> | |
inline void read(Tp &x) | |
{ | |
x = 0; | |
bool neg = false; | |
char c = getchar(); | |
for (; !isdigit(c); c = getchar()) | |
{ | |
if (c == '-') | |
{ | |
neg = true; | |
} | |
} | |
for (; isdigit(c); c = getchar()) | |
{ | |
x = x * 10 + c - '0'; | |
} | |
if (neg) | |
{ | |
x = -x; | |
} | |
} | |
const int N = 15; | |
const int M = 9; | |
const char desc[M] = {0, 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'}; | |
f128 man[N], os[N]; | |
unordered_map<char, int> dict; | |
inline void prepare() | |
{ | |
man[0] = 1.0L; | |
for (int i = 1; i < N; ++i) | |
{ | |
man[i] = man[i - 1] * 1000.0L; | |
} | |
os[0] = 1.0L; | |
for (int i = 1; i < N; ++i) | |
{ | |
os[i] = os[i - 1] * 1024.0L; | |
} | |
for (int i = 0; i < M; ++i) | |
{ | |
dict[desc[i]] = i; | |
} | |
} | |
char str[N]; | |
inline void solve() | |
{ | |
scanf("%s", str); | |
int cur = 0; | |
for (; isdigit(str[cur]); ++cur) | |
; | |
++cur; | |
char desc = 0; | |
for (; str[cur] != 'B'; ++cur) | |
{ | |
desc = str[cur]; | |
} | |
int p = dict[desc]; | |
f128 ans = (1.0L - man[p] / os[p]) * 100.0L; | |
ans = round(ans * 100.0L) / 100.0L; | |
printf("%.2lf%%\n", (f64)ans); | |
} | |
int main() | |
{ | |
prepare(); | |
int T; | |
read(T); | |
for (int cas = 1; cas <= T; ++cas) | |
{ | |
printf("Case #%d: ", cas); | |
solve(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment