如何获得错误的数据啊?是不是要付点费用就可以获得错误案例的数据啊? 这个题目,case1 没过。不知道咋回事?
#include <iostream>
#include <cstring>
#include <string.h>
using namespace std;
int g[505],a[20],ans[505];
int main()
{
long long k,x,s;
int c,b,i;
i=k=s=b=0;
cin>>k>>x;
if(k==0&&x==0){
cout<<0;
return 0;
}
s=x;
while(s!=0){ //倒序保存x。存在a数组里面。
c=s%10;
a[b]=c;
s=s/10;
b++;
}
b--;
for(i=0;i<k;i++) g[i]=0; //倒序保存10的K次方。
if(k==0){
cout<<x;
return 0;
}
g[i]=1;
int y = b;
if(k>b){
y = k;
}
for(int j=0;j<=y;j++){
int tmp = g[j]+a[j]+ans[j]; //处理进位。
if(tmp<9){
ans[j]=tmp;
}
else{
ans[j+1]+=tmp/10;
ans[j]=tmp%10;
if(j==y) y++;
}
}
for(i=y;i>=0;i--) cout<<ans[i];
cout<<endl;
}