structDice { longlongint top; longlongint front; longlongint bottom; longlongint behind; longlongint left; longlongint right; Dice() { top = 1; front = 2; bottom = 6; behind = 5; left = 4; right = 3; } voidtoTheRight(){ longlongint origTop = top; top = left; left = bottom; bottom = right; right = origTop; ans += top; }
voidtoTheLeft(){ longlongint origTop = top; top = right; right = bottom; bottom = left; left = origTop; ans += top; }
voidtoTheDownLine(){ longlongint origTop = top; top = behind; behind = bottom; bottom = front; front = origTop; ans += top; } } d;
longlongint n, m;
inlineintgetint(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -1; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
inlinevoidputint(int x, bool returnValue){ if (x < 0) { x = -x; putchar('-'); } if (x >= 10) putint(x / 10, false); putchar(x % 10 + '0'); if (returnValue) putchar('\n'); }
intmain(int argc, char *const argv[]){ cin >> n >> m; ans = 1; for (int i = 1; i <= n; ++i) { ans += ((m - 1) / 4 ) * 14; if (i & 1) for (int j = 1; j <= (m - 1) % 4; ++j) d.toTheRight(); else for (int j = 1; j <= (m - 1) % 4; ++j) d.toTheLeft(); // 在 toTheRight 和 toTheLeft 和 toTheDownLine 中已经更新过答案 // 不必再更新 if (i != n) d.toTheDownLine(); } cout << ans << endl; return0; }
int s[MAXN * 2]; // 前缀和数组 // 开两倍是因为对于每一个妹子都需要记录l和r两个变量
inlineintgetint(){ int s = 0, x = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') x = -1; ch = getchar(); } while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); } return s * x; }
inlinevoidputint(int x, bool returnValue){ if (x < 0) { x = -x; putchar('-'); } if (x >= 10) putint(x / 10, false); putchar(x % 10 + '0'); if (returnValue) putchar('\n'); }
intmain(int argc, char *const argv[]){ n = getint(); for (int i = 1; i <= n; ++i) { l[i] = getint(); r[i] = getint(); // 记录离散化数组 tmp[2 * i - 1] = l[i]; tmp[2 * i] = r[i]; } // 开始离散化 sort(tmp + 1, tmp + 1 + 2 * n); for (int i = 1; i <= n; ++i) { l[i] = lower_bound(tmp + 1, tmp + 1 + 2 * n, l[i]) - tmp; r[i] = lower_bound(tmp + 1, tmp + 1 + 2 * n, r[i]) - tmp; // 在离散化中顺便记录前缀和数组 ++s[l[i]]; --s[r[i] + 1]; } // 处理前缀和 for (int i = 1; i <= 2 * n; ++i) { s[i] += s[i-1]; } int ans = 0; for (int i = 1; i <= 2 * n; ++i) ans = std::max(ans, s[i]); putint(ans, true); return0; }