有没有好心人帮我测试一下(UVA绑不上)
查看原帖
有没有好心人帮我测试一下(UVA绑不上)
947202
wangruize88楼主2024/8/28 16:48

悬关,帮忙提交下程序

#include <stdio.h>
#include <string.h>
bool a[1048576] ;
int dfs ( int d , int i , int x ) {
	if ( x >= (1<<d-1) ) {
		if ( i>1 ) {
			dfs ( d , i-1 , 1 ) ;
		}
		else {
			printf ( "%d\n" , x ) ;
			return 0;
		}
	} else {
		if ( !a[x] ) a[x]=true , dfs ( d , i , 2*x ) ;
		else a[x]=false , dfs ( d , i , 2*x+1 ) ;
	}
	return 0;
}
int main () {
	int n , d , i ;
	scanf ( "%d" , &n ) ;
	for ( int j = 1 ; j <= n ; j++ ) {
		scanf ( "%d%d" , &d , &i ) ;
		dfs ( d , i , 1 ) ;
		memset ( a , 0 , sizeof a ) ;
	}
	return 0 ;
}

以上为C++代码,由于本蒟蒻一直绑定不了UVA,请路过的神犇帮个忙提交一下,告诉下我结果。
如果有神犇能优化代码更感谢!

2024/8/28 16:48
加载中...