class Solution {
public:
/**
* 返回一个严格四舍五入保留两位小数的字符串
* @param n int整型 n
* @return string字符串
*/
string Probability(int n) {
// write code here
if(n == 1){
return "1.00";
}
int m = pow(0.5, n) * 2000;
if(m % 10 >= 5){
m = m / 10 + 1;
} else{
m = m / 10;
}
string res = "0.00";
if(m < 10){
res[3] = m + '0';
} else{
res[3] = m % 10 + '0';
m /= 10;
res[2] = m + '0';
}
return res;
}
};
public:
/**
* 返回一个严格四舍五入保留两位小数的字符串
* @param n int整型 n
* @return string字符串
*/
string Probability(int n) {
// write code here
if(n == 1){
return "1.00";
}
int m = pow(0.5, n) * 2000;
if(m % 10 >= 5){
m = m / 10 + 1;
} else{
m = m / 10;
}
string res = "0.00";
if(m < 10){
res[3] = m + '0';
} else{
res[3] = m % 10 + '0';
m /= 10;
res[2] = m + '0';
}
return res;
}
};