第十七届浙大城市学院程序设计竞赛 L Sumo and Coins
Sumo and Coins
https://ac.nowcoder.com/acm/contest/5954/L
L Sumo and Coins
题目地址:
基本思路:
首先我们可以把翻转次转换为翻转一次,这样我们能明确NULL这种情况是不可能发生的,然后如果n是偶数那么我们思考一下一定是能做到ALL的,但是如果n是奇数,我们可以带几个数字试一下,我们能发现只能将初始偶数个的那一面全部翻到另一面,也就是哪一面初始为奇数那么就能全部翻转到哪一面。
参考代码:
#pragma GCC optimize(2) #pragma GCC optimize(3) #include <bits/stdc++.h> using namespace std; #define IO std::ios::sync_with_stdio(false) #define int long long #define rep(i, l, r) for (int i = l; i <= r; i++) #define per(i, l, r) for (int i = l; i >= r; i--) #define mset(s, _) memset(s, _, sizeof(s)) #define pb push_back #define pii pair <int, int> #define mp(a, b) make_pair(a, b) #define INF (int)1e18 inline int read() { int x = 0, neg = 1; char op = getchar(); while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); } while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); } return neg * x; } inline void print(int x) { if (x < 0) { putchar('-'); x = -x; } if (x >= 10) print(x / 10); putchar(x % 10 + '0'); } int n,a,b; signed main() { IO; int T; cin >> T; while (T--) { cin >> n >> a >> b; if (n == 1) { if (a > 0) cout << "UP" << '\n'; else if (b > 0) cout << "DOWN" << '\n'; continue; } if(n % 2 == 0){ cout << "ALL" << '\n'; }else{ if(a % 2 == 0) cout << "DOWN" << '\n'; else cout << "UP" << '\n'; } } return 0; }