2020年团体程序设计天梯赛 L1-8 刮刮彩票
思路:
水题,略过
Tip:
这题没想到很多人都错了,这里有两个容易错的点需要注意:
- (0 表示的是这个位置上的数字初始时就能看见了,而不是彩票上的数字为 0。)这句话特意标黑了,意思是1-9这九个数都出现仅出现一次,如果1-8出现了,那么这个0的位置代表9这个数字
- 翻开不翻开数字是不会变化的!我队友以为没被翻开的数就代表0,实际上翻不翻开不影响玩家选择的总和
#include <bits/stdc++.h> using namespace std; typedef long long ll; int a[5][5]; bool vis[10]; int indexx = 0, indexy = 0; int ans[25] = {0, 0, 0, 0, 0, 0, 10000, 36, 720, 360, 80, 252, 108, 72, 54, 180, 72, 180, 119, 36, 306, 1080, 144, 1800, 3600}; int main() { for (int i = 1; i <= 3; i++) for (int j = 1; j <= 3; j++) { cin >> a[i][j]; vis[a[i][j]] = true; if (a[i][j] == 0) { indexx = i; indexy = j; } } for (int i = 0; i <= 9; i++) if (!vis[i]) { a[indexx][indexy] = i; } for (int i = 1; i <= 3; i++) { int x, y; cin >> x >> y; cout << a[x][y] << endl; } int tmp; cin >> tmp; int now = 0; if (tmp == 1) now = a[1][1] + a[1][2] + a[1][3]; else if (tmp == 2) now = a[2][1] + a[2][2] + a[2][3]; else if (tmp == 3) now = a[3][1] + a[3][2] + a[3][3]; else if (tmp == 4) now = a[1][1] + a[2][1] + a[3][1]; else if (tmp == 5) now = a[1][2] + a[2][2] + a[3][2]; else if (tmp == 6) now = a[1][3] + a[2][3] + a[3][3]; else if (tmp == 7) now = a[1][1] + a[2][2] + a[3][3]; else if (tmp == 8) now = a[3][1] + a[2][2] + a[1][3]; cout << ans[now] << endl; return 0; }