大神说的水题没过(P6745)
  • 板块题目总版
  • 楼主wyq战车
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/3/9 23:58
  • 上次更新2023/10/28 06:56:29
查看原帖
大神说的水题没过(P6745)
655209
wyq战车楼主2022/3/9 23:58

如何获得错误的数据啊?是不是要付点费用就可以获得错误案例的数据啊? 这个题目,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;
}
2022/3/9 23:58
加载中...