POJ 1001 wrong answer ,我试了下题目上面给的例子,答案全部一样,可是提交时总是Wrong answer ,#include #include #define MAX 125#define BASE 6int main(void) {unsigned char input[BASE];unsigned int dim,changed[BASE - 1] = { 0 },y,te
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 19:40:50
POJ 1001 wrong answer ,我试了下题目上面给的例子,答案全部一样,可是提交时总是Wrong answer ,#include #include #define MAX 125#define BASE 6int main(void) {unsigned char input[BASE];unsigned int dim,changed[BASE - 1] = { 0 },y,te
POJ 1001 wrong answer ,我试了下题目上面给的例子,答案全部一样,可是提交时总是Wrong answer ,
#include
#include
#define MAX 125
#define BASE 6
int main(void) {
unsigned char input[BASE];
unsigned int dim,changed[BASE - 1] = { 0 },y,temp[MAX] = { 0 },result[MAX] =
{ 0 };
int dec,m,out,ispure,back,i,j,k,t,s,z;
memset(input,0,sizeof(input));
while (scanf("%s%d",input,&dim) == 2) {
memset(changed,0,sizeof(changed));
memset(temp,0,sizeof(temp));
memset(result,0,sizeof(result));
m = 0;
back = 0;
j = 0;
k = 1;
s = 0;
if (input[0] == '0')
ispure = 1;
else
ispure = 0;
for (i = 0; i < BASE; i++) {
if (input[BASE - 1 - i] == '.') {
dec = BASE - i - 1;
continue;
}
changed[j++] = input[BASE - i - 1] - '0';
if (s += changed[i]))
back = i + 1;
}
memcpy(temp,changed,sizeof(changed));
for (z = 0; z < dim - 1; z++) {
for (i = 0; i < MAX; i++)
for (j = 0; j < BASE - 1; j++) {
result[i + j] += temp[i] * changed[j];
}
for (i = 0; i < MAX; i++) {
result[i + 1] += result[i] / 10;
result[i] = result[i] % 10;
}
memset(temp,0,sizeof(temp));
memcpy(temp,result,sizeof(result));
memset(result,0,sizeof(result));
}
t = MAX + 1 - dim * (BASE - 1 - dec);
if (back)
out = dim * back;
else
out = 0;
if (ispure == 0) {
for (i = MAX - 1; i >= out; i--) {
if (temp[i] == 0 && m == 0) {
k++;
continue;
} else {
m = 1;
if (t == (k++))
printf(".");
printf("%d",temp[i]);
}
}
} else {
y = (BASE - dec - 1) * dim;
printf(".");
for (i = y - 1; i >= out; i--) {
printf("%d",temp[i]);
}
}
printf("\n");
}
return 0;
}
我的编译器是LINUX GCC 4.4.4版本的,这个东西写了一天了
POJ 1001 wrong answer ,我试了下题目上面给的例子,答案全部一样,可是提交时总是Wrong answer ,#include #include #define MAX 125#define BASE 6int main(void) {unsigned char input[BASE];unsigned int dim,changed[BASE - 1] = { 0 },y,te
先把你的程序的目的描述清楚方便大家给你看,要不你就好好做注释.