为什么会RE呀,样例都是都是正确的,自己造数据也没问题。
查看原帖
为什么会RE呀,样例都是都是正确的,自己造数据也没问题。
297451
turbine楼主2020/11/1 21:41
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int a[MAXN];
int k;
int main()
{
	char ch=getchar();
	while(ch>='0'&&ch<='9'){
		a[k++]=ch-'0';
		ch=getchar();
	}
	for(int i=0;i<k/2;i++){
		int temp=a[i];
		a[i]=a[k-i-1];
		a[k-i-1]=temp;
	}
	for(int i=0;i<k;i++)
		a[i]*=2;
	for(int i=0;i<k;i++){
		if(a[i]>=10){
			a[i+1]+=a[i]/10;
			a[i]%=10;
			if(i==k-1)
				k++;
		}
	}
	if(a[0])
		a[0]-=1;
	else{
		int i=0;
		while(a[i]==0){
			a[i]=9;
			i++;
		}
		a[i]-=1;
	}
	for(int i=k-1;i>=0;i--){
		cout<<a[i];
	}
	return 0;
}
2020/11/1 21:41
加载中...