跳到正文

题解

题解:P11143 「SFMOI Round I」Strange Cake Game

用户 903687约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 2 分钟
获赞
1
题目
P11143

版本

  1. v1当前

简单博弈,划分的面积肯定是越大越好,

所以从原点走一条折线到终点肯定最优,判断是否蛋糕在折线上方。

AC代码:

C++
#include<bits/stdc++.h>
using namespace std;
#define int long long
int rd() {
	int x = 0, w = 1;
	char ch = 0;
	while (ch < '0' || ch > '9') {
		if (ch == '-') w = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + (ch - '0');
		ch = getchar();
	}
	return x * w;
}
void wt(int x) {
	static int sta[35];
	int f = 1;
	if(x < 0) f = -1,x *= f;
	int top = 0;
	do {
		sta[top++] = x % 10, x /= 10;
	} while (x);
	if(f == -1) putchar('-');
	while (top) putchar(sta[--top] + 48);
}
const int N = 2e5+5;
int n,m,k;
signed main() {
    n = rd(),m = rd();
    k = rd();
    int ans = 0;
    for(int i = 1;i<=k;i++) {
        int x = rd(),y = rd();
        if(x > y) ans++;
    }
    wt(k - ans);
	return 0;
}
原文