hack
查看原帖
hack
592238
Elairin176楼主2022/12/17 17:03
#include <iostream>
using namespace std;
int t,m,x,y;
bool vis[10010][10010];
inline void dfs(int x,int y){
	if(x==0){
		printf("1\n");
		return;
	}else if(y==0){
		printf("2\n");
		return;
	}
	x=(x+y)%m;
	y=(x+y)%m;
	if(vis[x][y]){
		printf("error\n");
		return;
	}
	vis[x][y]=true;
	dfs(x,y);
}
int main(void){
	scanf("%d%d",&t,&m);
	while(t--){
		scanf("%d%d",&x,&y);
		dfs(x,y);
	}
}

这是我的程序,AC 了。
但是用以下数据就可以卡死这个程序:

in:
2 10
4 5
4 5
out:
1
1

我程序输出是:

1
error

显然不对。

2022/12/17 17:03
加载中...