题解 AT5665 【DDCC Finals】

这道题目真是红!而我没用if,因为对于每种比赛而言,设rank\large rank\, = 排名,只要排名前3以内,其获得奖金为:

(3rank+1)100000)\Large (3\, -\, rank\, + \,1) \,* \,100000)

那么,如果rank>3\large \,rank\,>\,3,那么我们的结果为0,为了抵消,我们将rank\large \,rank\,设为4,则3rank+1=0\large \, 3 \, - \, rank \, + \, 1 \, = \, 00100000=0\large 0\, * \,100000\, = \,0,抵消掉。

代码(使用new与delete,其实没有必要):

#include <iostream>
using namespace std;

const int N = 1e5;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int *a = new int(), *b = new int(); // new int(),括号中可以填写也可以不填写
    cin >> *a >> *b;
    if(*a > 3) *a = 4;
    if(*b > 3) *b = 4;
    cout << (3 - *a + 1) * N + (3 - *b + 1) * N + (*a == 1 && *b == 1 ? 4 * N : 0) << endl;
    delete a;
    delete b;
    return 0;
}
posted @   HappyBobb  阅读(2)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示