首页 > 其他 > 详细

Educational Codeforces Round 88 (Rated for Div. 2)

时间:2020-06-07 16:55:15      阅读:33      评论:0      收藏:0      [点我收藏+]

题目传送门

A. Berland Poker

技术分享图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

int n, m, k;
void solve()
{
    cin >> n >> m >> k;
    if (m <= n / k)
        cout << m << endl;
    else
        cout << n / k - ceil(1.0 * (m - n / k) / (k - 1)) << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
View Code

 

B. New Theatre Square

技术分享图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

int n, m, x, y, ans;
char mp[1010];
void solve()
{
    cin >> n >> m >> x >> y;
    ans = 0;
    rep(i, 1, n)
    {
        cin >> mp + 1;
        if (y >= 2 * x)
            rep(j, 1, m)
            {
                if (mp[j] == .)
                    ans += x;
            }

        else
            rep(j, 1, m) if (mp[j] == .)
            {
                if (mp[j + 1] == .)
                    ans += y;
                else
                    ans += x;
                j++;
            }
    }
    cout << ans << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
View Code

 

C. Mixing Water

技术分享图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

ll c, h, t;
void solve()
{
    cin >> h >> c >> t;
    if (h == t)
    {
        puts("1");
        return;
    }
    if (h + c >= 2 * t)
    {
        puts("2");
        return;
    }
    ll l = 1, r = 1000000;
    while (l < r)
    {
        int mid = (l + r) / 2;
        if ((double)1.0 * (mid * h + (mid - 1) * c) / (2 * mid - 1) > t)
            l = mid + 1;
        else
            r = mid;
    }
    if (fabs(t - (double)1.0 * (l * h + (l - 1) * c) / (2 * l - 1)) < fabs(t - (double)1.0 * ((l - 1) * h + (l - 2) * c) / (2 * l - 3)))
        cout << 2 * l - 1 << endl;
    else
        cout << 2 * l - 3 << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
View Code

 

D. Yet Another Yet Another Task

 

Educational Codeforces Round 88 (Rated for Div. 2)

原文:https://www.cnblogs.com/likunhong/p/13032042.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!