Codeforces Round #664 (Div. 2) B. Boboniu Plays Chess
程序员文章站
2022-03-11 21:59:06
题目链接思路:走过的方格是不能再走的,每个方格都要走一遍,输出路径。代码:#include#define int long long#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);const int N=355;const int M=2e4+5;const double eps=1e-8;const int mod=998244353;const int inf=0...
题目链接
思路:
走过的方格是不能再走的,每个方格都要走一遍,输出路径。
代码:
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N=355;
const int M=2e4+5;
const double eps=1e-8;
const int mod=998244353;
const int inf=0x7fffffff;
const double pi=3.1415926;
using namespace std;
int mp[110][110],sum[110];
signed main()
{
IOS;
int n,m,x,y;
cin>>n>>m>>x>>y;
int cnt=1,sign=n*m;
cout<<x<<' '<<y<<endl;
mp[x][y]=1;
sum[x]++;
while(cnt<sign)
{
if (sum[x]!=m)
{
while (mp[x][y])
{
y=(y+1)%(m+1);
if(y==0)
{
y++;
}
}
cnt++;
sum[x]++;
mp[x][y]=1;
cout<<x<<' '<<y<<endl;
}
else
{
while(mp[x][y])
{
x=(x+1)%(n+1);
if(x==0)
x++;
}
cnt++;
sum[x]++;
mp[x][y]=1;
cout<<x<<' '<<y<<endl;
}
}
return 0;
}
本文地址:https://blog.csdn.net/ACkingdom/article/details/108114824
推荐阅读
-
Codeforces Round #649 (Div. 2)-B. Most socially-distanced subsequence(思维)
-
Codeforces Round #461 (Div. 2) B. Magic Forest(异或的性质)
-
Codeforces Round #663 (Div. 2) B. Fix You
-
Codeforces Round #658 (Div. 2) B. Sequential Nim
-
B. Power Sequence(数学+枚举)Codeforces Round #666 (Div. 2)
-
Codeforces Round #666 (Div. 2)B. Power Sequence(等比数列)
-
Codeforces Round #664 (Div. 2) B. Boboniu Plays Chess
-
Codeforces Round #664 (Div. 2) A. Boboniu Likes to Color Balls
-
Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi (超几何
-
Codeforces Round #258 (Div. 2) B. Sort the Array (模拟)