- 清帝之惑之乾隆
- 2015-04-09 21:47:03 @
编译成功
测试数据 #0: Accepted, time = 78 ms, mem = 1024 KiB, score = 10
测试数据 #1: WrongAnswer, time = 234 ms, mem = 1028 KiB, score = 0
测试数据 #2: Accepted, time = 124 ms, mem = 1028 KiB, score = 10
测试数据 #3: Accepted, time = 62 ms, mem = 1028 KiB, score = 10
测试数据 #4: WrongAnswer, time = 62 ms, mem = 1028 KiB, score = 0
测试数据 #5: Accepted, time = 93 ms, mem = 1024 KiB, score = 10
测试数据 #6: Accepted, time = 93 ms, mem = 1024 KiB, score = 10
测试数据 #7: Accepted, time = 46 ms, mem = 1032 KiB, score = 10
测试数据 #8: Accepted, time = 15 ms, mem = 1024 KiB, score = 10
测试数据 #9: Accepted, time = 15 ms, mem = 1028 KiB, score = 10
WrongAnswer, time = 822 ms, mem = 1032 KiB, score = 80
代码:
#include <vector>
#include <list>
#include <limits.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <memory.h>
using namespace std;
int n,big[40000],ans[40000],len,lena,point;
bool init()
{
int temp,now;
char s[15];
len = 0;
temp = 0;
memset(big,0,sizeof(big));
memset(ans,0,sizeof(ans));
if (scanf("%s",s) != 1)
return false;
scanf("%d",&n);
for (now = 0; s[now] != '.'; ++ now)
{
temp *= 10;
temp += s[now] - '0';
}
point = 0;
for (++ now; now < 6; ++ now)
{
temp *= 10;
temp += s[now] - '0';
++ point;
}
while (temp % 10 == 0 && point > 0)
{
temp /= 10;
-- point;
}
while (temp != 0)
{
++ len;
big[len] = temp % 10;
temp /= 10;
}
lena = len;
memcpy(ans,big,sizeof(ans));
return true;
}
void large()
{
int a[40000],b[40000],c[40000];
memset(c,0,sizeof(c));
memcpy(a,big,sizeof(big));
memcpy(b,ans,sizeof(ans));
for (int i = 1; i <= lena; ++ i)
for (int j = 1; j <= len; ++ j)
c[i+j-1] += a[i] * b[j];
len += lena + 5;
for (int i = 1; i <= len; ++ i)
{
c[i+1] += c[i] / 10;
c[i] %= 10;
}
while (c[len] == 0)
-- len;
memcpy(ans,c,sizeof(c));
}
int main()
{
while(init())
{
if (n == 0)
{
printf("1\n");
continue;
}
point *= n;
for (int i = 2; i <= n; ++ i)
large();
if (point >= len)
{
printf(".");
for (int j = point; j > 0; -- j)
printf("%d",ans[j]);
}
else
{
for (int j = len; j > point; -- j)
printf("%d",ans[j]);
if (point == 0)
continue;
printf(".");
for (int j = point; j > 0; -- j)
printf("%d",ans[j]);
}
printf("\n");
}
return 0;
}
本地对拍一个AC程序无误,就是过不了……求助!!
2 条评论
-
coolxxx LV 9 @ 2016-04-01 21:35:45
我也是这样!但是我看了一遍发现没少回车啊
-
2015-04-09 21:57:58@
已解决,少了个回车
- 1