牛客周赛 Round 58
A
模拟
1 2 3 4 5 6 7 8 9 10
| #include <bits/stdc++.h> using namespace std; int main(){ double a, b; cin >> a >> b; if(b - a > 0) cout << "YES" << endl; else cout << "NO" << endl; }
|
B
看看有没有比前面一个数字大就行。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; bool flag = true; for(int i = 0;i<s.size()-1;i++) { if(s[i] < s[i+1]) { flag = false; break; } } if(flag) cout << "NO" << endl; else cout << "YES" << endl; } int main() { int t; cin >> t; while(t--) solve(); return 0; }
|
C
猜猜题。有可能会有人乱走,因此一定需要绝对值小于或者等于1才可能会出现不平局的情况。
相等就是输了,差1就是赢了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <iostream>
using namespace std;
void solve() { int x, y; cin >> x >> y;
if (x == y && x >= 0 && y >= 0) { if (x == 0 && y == 0) cout << "Yes" << endl;
cout << "NO" << endl; }
else if ((x == y + 1 || y == x + 1) && x >= 0 && y >= 0) cout << "YES" << endl;
else cout << "PING" << endl; }
int main() { int t; cin >> t;
while (t--) solve();
return 0; }
|
D
进制题,输出在k进制表示下最大的数字即可。由于1是可以弄出全部的,因此需要特判掉。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #include <bits/stdc++.h> using i64 = long long; using namespace std; void solve() { i64 n, k; cin >> n >> k; if (k == 1) { cout << 1 << '\n'; } else { i64 ans = 0; while (n) { ans = max(ans, n % k); n /= k; } cout << ans << '\n'; } } int main() { int t; cin >> t; while (t--) solve(); return 0; }
|
E
也是猜猜题。
如果m>3一定不可能。
否则大概率就是
0111
00222
000333这一类的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| #include <bits/stdc++.h> using namespace std; using i64 = long long; using u64 = unsigned long long;
void solve() { int n, m; cin >> n >> m; if (m > 3) { cout << 0 << '\n'; return; } if (n == 1) { cout << 2 << '\n'; return; } if (m == 1) { cout << n + 1 << '\n'; return; } if (m == 2) { cout << n << '\n'; return; } if (m == 3) { cout << 1 << '\n'; return; } }
signed main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0);
i64 t = 1; cin >> t; while (t--) { solve(); } }
|
F
是个主席树板子。