请问各位神仙觉得这题是绿题的原因是什么QwQ
查看原帖
请问各位神仙觉得这题是绿题的原因是什么QwQ
359283
ElzaYork楼主2022/7/10 19:37

RT。窝觉得完全没有绿题这么恐怖吧qaq,毕竟这题窝这个小蒟蒻15分钟就做出来了。

想了解下是不是各位神仙的思路与窝不同qaq

(丢一下窝的做法,没有神仙们说的分讨/找规律,只是很普通的枚举每一位,然后按位填充qwq)

#include<bits/stdc++.h>
//#define int ll
using namespace std;
typedef unsigned long long ll;
inline ll read(){
	ll x=0;char c=getchar();
	while(c<'0'||c>'9'){c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x;
}
ll n,pw[20];
int a[20];
int main(){int tests=1;tests=read();
pw[0]=1;for(int i=1;i<=19;i++) pw[i]=pw[i-1]*10;
while(tests--){
	n=read();
	int m=0;
	ll x=n;
	while(x) a[++m]=x%10,x/=10;
	for(int i=1,j=m;i<j;i++,j--) a[i]^=a[j]^=a[i]^=a[j];
	a[m+1]=326;
	bool ok=0;
	ll ans=1e18+1,res;
	for(int i=1;i<=m;i++){
		if(a[i]!=9){
//			printf("i:%d\n",i);
			if(i==m){
				res=a[i]+1;
			}
			else res=1;
			for(int j=m-1;j>i;j--) res*=10;
			if(i!=m) res = res * 10 + a[i] + 1;
			for(int j=i-1;j;j--) res = res * 10 + a[j];
			ok=1;
			ans=min(ans,res);
		}
	}
	if(!ok) ans=pw[m]+1;
	printf("%llu\n",ans-1);
}	return 0;
}

2022/7/10 19:37
加载中...