Commentary Boxes CodeForces - 990A(水题)

解决足球赛事中评论箱分配问题,确保每个代表团获得相同数量的评论箱。通过新建或拆除评论箱来达到总数能被代表团数量整除的目标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Commentary Boxes
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Berland Football Cup starts really soon! Commentators from all over the world come to the event.

Organizers have already built nn commentary boxes. mm regional delegations will come to the Cup. Every delegation should get the same number of the commentary boxes. If any box is left unoccupied then the delegations will be upset. So each box should be occupied by exactly one delegation.

If nn is not divisible by mm, it is impossible to distribute the boxes to the delegations at the moment.

Organizers can build a new commentary box paying aa burles and demolish a commentary box paying bb burles. They can both build and demolish boxes arbitrary number of times (each time paying a corresponding fee). It is allowed to demolish all the existing boxes.

What is the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by mm)?

Input

The only line contains four integer numbers nnmmaa and bb (1n,m10121≤n,m≤10121a,b1001≤a,b≤100), where nn is the initial number of the commentary boxes, mm is the number of delegations to come, aa is the fee to build a box and bb is the fee to demolish a box.

Output

Output the minimal amount of burles organizers should pay to satisfy all the delegations (i.e. to make the number of the boxes be divisible by mm). It is allowed that the final number of the boxes is equal to 00.

Examples
input
Copy
9 7 3 8
output
Copy
15
input
Copy
2 7 3 7
output
Copy
14
input
Copy
30 6 17 19
output
Copy
0
Note

In the first example organizers can build 55 boxes to make the total of 1414 paying 33 burles for the each of them.

In the second example organizers can demolish 22 boxes to make the total of 00 paying 77 burles for the each of them.

In the third example organizers are already able to distribute all the boxes equally among the delegations, each one get 55

 boxes


题意:给出n,m,a,b。表示有n个休息室,m个代表团,每个代表团必须有同样的休息室,如果m不能被n整除的话,你可以拆除,或新建一些休息室,新建花费a,拆除花费b,问怎么使花费最少。

思路:比较第一个比m小的m的倍数和第一个比m大的倍数的花费即可。

#include "iostream"
#include "algorithm"
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    ll n,m,a,b;
    cin>>n>>m>>a>>b;
    if(n%m==0)
        cout<<"0"<<endl;
    else{
        ll x=n/m;
        ll y=(n/m)+1;
        cout<<min((y*m-n)*a,(n-m*x)*b)<<endl;
    }
    return 0;
}

### 关于 `news-commentary-v15` 语料的相关信息 #### 数据集简介 `news-commentary-v15` 是一个广泛使用的双语文本对齐数据集,主要用于机器翻译任务的研究和开发。该数据集由新闻评论和其他公开可用的平行语料组成,涵盖了多种语言对,其中包括英语到中文的语言对[^1]。 #### 下载地址 `news-commentary-v15` 的官方版本通常可以通过 OPUS 平台获取。OPUS 提供了经过预处理的平行语料库,支持多种文件格式(如 `.tsv` 或 `.txt`)。以下是其下载页面链接: - 官方下载地址: https://opus.nlpl.eu/News Commentary.php 具体来说,`news-commentary-v15.en-zh.tsv` 文件包含了英文与中文之间的平行句对,适用于训练神经机器翻译模型或其他自然语言处理任务中的跨语言应用。 #### 使用说明 在实际项目中,如果要使用此数据集,则需按照如下方式进行操作: 1. **加载数据**: 将 TSV 文件读入程序并解析成源语言和目标语言两列。 示例代码展示如何从 `.tsv` 文件中加载句子对: ```python import pandas as pd # 加载TSV文件 df = pd.read_csv('path/to/news-commentary-v15.en-zh.tsv', sep='\t', header=None, names=['en', 'zh']) # 查看前几条记录 print(df.head()) ``` 2. **清理与预处理**: 对原始文本执行必要的清洗工作,比如移除特殊字符、统一大小写形式以及分词等步骤。 3. **分割训练验证测试集合**: 根据需求划分数据子集以便后续建模过程顺利开展。 4. **保存为适合框架输入的形式**: 转换成特定深度学习框架所需的格式 (例如 TensorFlow Record 或 PyTorch Dataset)。 #### 数据集特点 相比其他类型的语料库,`news-commentary-v15` 具备以下几个显著优势: - 高质量的人工翻译内容; - 来源于真实世界的新闻报道材料,具备较高的领域代表性; - 支持多国语言间的转换实验设计。 尽管如此,在利用此类公共资源时也应注意版权归属及相关法律条款约束。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值