UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#214954#3855. 好数MapleCompile Error//C++462b2024-11-24 12:34:052024-11-24 13:16:12

answer

#include<iostream>
#include<cstdio>
using namespace std;
int q;
int f(int y){
	int p=1;
	int x=y;
	while(x){
		x&=x-1;
		p<<=1;
	}
	return p;
}
int main(){
	//freopen("ex_number3.in","r",stdin);
	
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		int l,r;
		int t=0;
		scanf("%d%d",&l,&r);
		for(int j=l;j<=r;j++){
			int k=f(j);
			if(j%k==0&&(j/k)%2==1){
				printf("%d\n",j);
				t=1;
				break;
			}
		}
		if(!t)printf("%d\n",-1);
	}

详细

answer.code: In function 'int main()':
answer.code:31:2: error: expected '}' at end of input
  }\x0d
  ^
answer.code:17:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&q);\x0d
                ^
answer.code:21:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&l,&r);\x0d
                      ^