20,暴力枚举抽位%4,求捞
查看原帖
20,暴力枚举抽位%4,求捞
1481109
zhangshuran楼主2024/12/24 22:40
#include<bits/stdc++.h>
using namespace std;
long long n,w[3005];
int t,s;
bool pan(long long a){
	int a1=a;
	if(a%4==0){
		return 1;
	}
	if(a/10==0){
		return 0;
	}
	while(a1){
		w[++s]=a1%10;
		a1/=10;
	}
	for(int i=1;i<=s;i++){
		for(int j=i;j<=s;j++){
			if(i==1&&j==s) continue;
			int s1=0;
			long long l=0;
			for(int x=s;x>=1;x--){
				if(x>=i&&x<=j) continue;
				l+=pow(10,s1)*w[x];
				s1++;
			}
			if(l%4==0){
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	cin>>t;
	while(t--){
		cin>>n;
		if(pan(n)){
			cout<<"Yes\n";
		}
		else{
			cout<<"No\n";
		}
		for(int i=1;i<=3005;i++) w[i]=0;
		n=0;
	}
	return 0;
}
2024/12/24 22:40
加载中...