Codeforces 451C Predict Outcome of the Game(暴力),codeforces451c

來源:互聯網
上載者:User

Codeforces 451C Predict Outcome of the Game(暴力),codeforces451c

題目串連:Codeforces 451C Predict Outcome of the Game

題目大意:題意有點坑,就是三支球隊有n場比賽,錯過了k場,即這k場比賽不知道輸贏,只知道第一支球隊和第二支球隊勝局情況差d1,第二和第三差d2,問說最後有沒有可能三支隊伍勝局數相同。

解題思路:考慮四種情況下的場數u,是否為3的倍數,u/3後是否比當前情況下勝局數最高的隊伍大,並且還要判斷該情況是否可行。

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;ll n, k, d1, d2;bool check (ll u, ll t) {    if (u % 3 || u > n)        return false;    return u / 3 >= t;}bool judge () {    if (n % 3)        return false;    /*        */    if (check(n - k + d1 + d2 * 2, d1 + d2))        return true;    if (check(n - k + 2 * d1 + d2, d1 + d2))        return true;    if (check(n - k + d1 + d2, max(d1, d2)))        return true;    if (check(n - k + 2 * max(d1, d2) - min(d1, d2), max(d1, d2)))        return true;    return false;}int main () {    int cas;    scanf("%d", &cas);    for (int i = 0; i < cas; i++) {        scanf("%lld%lld%lld%lld", &n, &k, &d1, &d2);        printf("%s\n", judge() ? "yes" : "no");    }    return 0;}



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.