II play with GG
生活随笔
收集整理的這篇文章主要介紹了
II play with GG
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
https://ac.nowcoder.com/acm/contest/338/I
C++版本一
題解:首先輪到出手的時候如果在(0,0)上肯定是輸的,而(0,1)(1,0)(0,2)(2,0)(1,1)肯定是贏的;
往上遞推,某一個(x,y)如果可以走的(x-1,y)(x,y-1)(x-1,y-1)三點都是必輸的,那么在(x,y)的人必輸。
?
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int using namespace std; typedef long long ll; //typedef __int128 lll; const int N=1000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,q,ans; bool a[N][N]; char str; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endifscanf("%d%d",&n,&m);a[0][0]=0;a[1][0]=a[0][1]=1;a[1][1]=1;for(int i=0;i<=n;i++){for(int j=0;j<=m;j++){if(i-1>=0&&j-1>=0){if(a[i][j-1]&&a[i-1][j]&&a[i-1][j-1])a[i][j]=0;elsea[i][j]=1;}else if(i-1>=0){if(a[i-1][j])a[i][j]=0;elsea[i][j]=1;}else if(j-1>=0){if(a[i][j-1])a[i][j]=0;elsea[i][j]=1;}}}if(a[n][m]){cout << "ii" << endl;}else{cout << "gg" << endl;}//cout << "Hello world!" << endl;return 0; }C++版本二
題解:根據C++版本一打表輸出以后
所以有了以下更簡單版本
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int using namespace std; typedef long long ll; //typedef __int128 lll; const int N=1000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,q,ans; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endifscanf("%d%d",&n,&m);if(n%2==0&&m%2==0){cout << "gg" << endl;}else{cout << "ii" << endl;}//cout << "Hello world!" << endl;return 0; }?
總結
以上是生活随笔為你收集整理的II play with GG的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Kuangyeye and hambur
- 下一篇: Less taolu