这个div2 的AB 还是很简单的,C题思路简单,但是这个模拟不好写啊。
这个题目的意思就是说让你判断z是不是会影响x,y进行大小的比较。
这个很简单。
#include <iostream> #include <algorithm> #include <cstdio> #include <string.h> #include <queue> #include <cmath> using namespace std; int main() { int x, y, z; scanf("%d%d%d", &x, &y, &z); if (z > 0 && abs(x - y) <= z) printf("?\n"); else if (x > y) printf("+\n"); else if (y > x) printf("-\n"); else if (x == y) printf("0\n"); return 0; }
这个B题也很简单,看题就应该会了吧。
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <queue> #include <cmath> using namespace std; int main() { int n; scanf("%d", &n); int m = ((n - 1) % 2 == 0 ? (n - 1) / 2 : ((n - 1) / 2 + 1)) + 1; printf("%d\n", m); printf("1 1\n"); n--; int r = 1, c = 1; while(n--) { if (r >= m) c++; else r++; printf("%d %d\n", r, c); } }
模拟题,挺麻烦的。
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <queue> #include <cmath> using namespace std; const int maxn = 2e5 + 10; int a[maxn],b[maxn]; int num[maxn]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for(int i=1;i<=n;i++) { scanf("%d", &b[i]); num[b[i]] = i; } bool flag = false; int tot = b[n]; while (tot != 1 && num[tot] == num[tot - 1] + 1) tot--; if(tot==1) { //printf("www %d\n", b[n]); for(int i=b[n]+1;i<=n;i++) { // printf("i=%d %d\n", i, num[i]); if (num[i] > i - b[n] - 1) { flag = true; break; } } if(!flag) { printf("%d\n", n - b[n]); return 0; } } int ans = n, mark = 0; int cnt = num[1]; for(int i=1;i<=n;i++) { if (num[i] < cnt) cnt++; else while (num[i] >= cnt) cnt++; //printf("num[%d]=%d cnt=%d\n", i, num[i], cnt); if(cnt>=n) { mark = i; break; } } ans += (n - mark) + (cnt - n); printf("%d\n", ans); return 0; }
Codeforces Round #564 (Div. 2)
原文:https://www.cnblogs.com/EchoZQN/p/11004330.html