zl程序教程

您现在的位置是:首页 >  其它

当前栏目

【Educational Codeforces Round 35 B】Two Cakes

Codeforces round 35 two Educational
2023-09-14 09:03:45 时间

【链接】 我是链接,点我呀:)
【题意】

在这里输入题意

【题解】

从小到大枚举x. 看看a/x+b/x是不是大于等于n 是的话。 看看是不是两种蛋糕都能凑一堆。 也即x的最大枚举量是min(a,b) 不然可能有多余的a%x没地方放。(因为它都还没有一堆

【代码】

#include <bits/stdc++.h>
using namespace std;

int n,a,b;

int main(){
	#ifdef LOCAL_DEFINE
	    freopen("rush_in.txt", "r", stdin);
	#endif
	ios::sync_with_stdio(0),cin.tie(0);
    cin >> n >> a >> b;
    int ans = 1;
    for (int i = 1;i <= min(a,b);i++){
        int temp = a/i + b/i;
        if (temp>=n){
            ans = i;
        }
    }
    cout << ans << endl;
	return 0;
}