求大神纠错!!!!

测试数据 #0: Accepted, time = 11 ms, mem = 584 KiB, score = 2
测试数据 #1: Accepted, time = 15 ms, mem = 576 KiB, score = 2
测试数据 #2: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #3: Accepted, time = 0 ms, mem = 588 KiB, score = 2
测试数据 #4: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #5: WrongAnswer, time = 0 ms, mem = 584 KiB, score = 0
测试数据 #6: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #7: WrongAnswer, time = 0 ms, mem = 584 KiB, score = 0
测试数据 #8: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #9: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #10: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #11: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #12: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #13: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #14: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #15: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #16: WrongAnswer, time = 0 ms, mem = 584 KiB, score = 0
测试数据 #17: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #18: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #19: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #20: Accepted, time = 15 ms, mem = 584 KiB, score = 2
测试数据 #21: Accepted, time = 15 ms, mem = 584 KiB, score = 2
测试数据 #22: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #23: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #24: Accepted, time = 7 ms, mem = 580 KiB, score = 2
测试数据 #25: Accepted, time = 0 ms, mem = 576 KiB, score = 2
测试数据 #26: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #27: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #28: WrongAnswer, time = 0 ms, mem = 588 KiB, score = 0
测试数据 #29: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #30: WrongAnswer, time = 0 ms, mem = 584 KiB, score = 0
测试数据 #31: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #32: Accepted, time = 15 ms, mem = 584 KiB, score = 2
测试数据 #33: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #34: Accepted, time = 0 ms, mem = 588 KiB, score = 2
测试数据 #35: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #36: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #37: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #38: Accepted, time = 15 ms, mem = 584 KiB, score = 2
测试数据 #39: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #40: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #41: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #42: Accepted, time = 0 ms, mem = 580 KiB, score = 2
测试数据 #43: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #44: Accepted, time = 15 ms, mem = 588 KiB, score = 2
测试数据 #45: Accepted, time = 15 ms, mem = 584 KiB, score = 2
测试数据 #46: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #47: WrongAnswer, time = 0 ms, mem = 580 KiB, score = 0
测试数据 #48: Accepted, time = 0 ms, mem = 584 KiB, score = 2
测试数据 #49: Accepted, time = 0 ms, mem = 580 KiB, score = 2
WrongAnswer, time = 123 ms, mem = 588 KiB, score = 74
代码
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,ans[2005],d[2005],y[2005],a,la,lans=1,ld=1;
void anschengd()
{
memset(y,0,sizeof(y));
for(int i=0;i<lans;i++)
for(int j=0;j<ld;j++)
{
y[i+j]+=ans[i]*d[j];
y[i+j+1]+=y[i+j]/10;
y[i+j]%=10;
}
lans+=ld;
if(y[lans-1]==0) lans--;
for(int i=0;i<lans;i++) ans[i]=y[i];
}
void dchengd()
{
memset(y,0,sizeof(y));
for(int i=0;i<ld;i++)
for(int j=0;j<ld;j++)
{
y[i+j]+=d[i]*d[j];
y[i+j+1]+=y[i+j]/10;
y[i+j]%=10;
}
ld+=ld;
if(y[ld-1]==0) ld--;
for(int i=0;i<ld;i++) d[i]=y[i];

}
void ansxhenga()
{
for(int i=0;i<lans;i++) ans[i]*=a;
for(int i=0;i<lans+1;i++)
{
ans[i+1]+=ans[i]/10;
ans[i]%=10;
}
if(ans[lans]) lans++;
}
int main()
{
cin>>n;
if(n<=3) {cout<<n<<endl;return 0;}
la=n/3;
n%=3;
if(n==1) {la--;a=4;}
if(n==2) a=2;
else a=1;
d[0]=3;
ans[0]=1;
while(la)
{
if(la%2!=0) anschengd();
dchengd();
la>>=1;
}
if(a!=1)
anschengd();
for(int i=lans-1;i>=0;i--) cout<<ans[i];
cout<<endl;
return 0;
}

1 条评论

  • @ 2014-11-05 00:01:23

    有几个地方乘号没了不要在意这些细节

    • @ 2014-11-05 20:39:16

      噗你不知道有种东西叫做代码块缩进吗
      ——选择代码块然后按下Tab键显示就科学了

    • @ 2014-11-05 20:58:39

      哦,谢谢

  • 1

信息

ID
1033
难度
5
分类
其他 | 数学 点击显示
标签
(无)
递交数
3722
已通过
1204
通过率
32%
被复制
9
上传者