两样例全过结果10分求助
查看原帖
两样例全过结果10分求助
381864
mousezzk楼主2023/8/1 19:45
#include<bits/stdc++.h>
using namespace std;
int t,x,s;
int pd(int x){
	if(x%7==0) return 1;
	while(x%2==0){
		int y=x;
		while(y>1){
			s=y%10;
			if(s==7) return 1;
			y/=10;
		}
		x/=2;
	}
	int y=x;
	while(y>1){
		s=y%10;
		if(s==7) return 1;
		y/=10;
	}
	return 0;
}
int main(){
	scanf("%d",&t);
	while(t--){
		scanf("%d",&x);
		if(pd(x)) cout<<-1<<endl;
		else{
			for(;;){
				x++;
				if(pd(x)==0){
					cout<<x<<endl;
					break;
				}
			}
		}
	}
	return 0;
}
2023/8/1 19:45
加载中...