【发布时间】:2015-10-01 22:23:50
【问题描述】:
我目前正在为自己的练习做this problem。我设法通过了所有测试用例,所以我不知道出了什么问题。我的代码是:
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
int main(){
int num = 1;
while(true){
string line,stringRes;
getline(cin,line);
if(cin.eof()){break;}
long double shrinks = atof(line.c_str());
long double triangels = pow(3,shrinks);
long double length = 3/pow(2,shrinks);
long double res = floor(triangels* length * 3);
int i = 0;
while(res >= 10){
i++;
res = res/10;
};
if(shrinks == 1){
printf("Case %d: %d\n",num ,1);
}else{
printf("Case %d: %d\n",num ,i+1);
}
num++;
}
return 0;
}
例如,当我输入 1000 时,我得到 178,而 10000 我得到 1762。
输入样本
0
1
5
10
100
输出样本
Case 1: 1
Case 2: 1
Case 3: 2
Case 4: 3
Case 5: 19
对于每个案例,显示案例编号,后跟代表给定迭代次数的圆周整数部分所需的小数位数。遵循示例输出的格式。
【问题讨论】:
-
标题中请仅使用英文字母。
-
您能否添加有关预期输出是什么以及实际输出是什么的详细信息?
-
我只是使用问题的名称。我链接了问题,但我会添加测试样本。