[CF1303B] National Project - 数学

Solution
- \(2a>n\),一次性结束,直接输出 \(n\)
- \(a \geq b\),那么一直修即可,直接输出 \(n\)
- 否则,\(a\) 占弱势,我们考虑用 \(a\) 修一半需要的完整轮次数为 \([(n-1)/2a]\) ,那么这些轮中, \(a\) 修掉的个数为 \([n/2a]a\),而 \(b\) 修掉的个数则是 \([n/2], [n/2a]b\) 中的较小值。计算剩余量然后暴力修即可。
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,a,b;
signed main() {
int t;
cin>>t;
while(t--) {
cin>>n>>a>>b;
if(2*a>n || a>=b) {
cout<<n<<endl;
}
else {
int d=(n-1)/(2*a);
int xa=d*a;
int xb=min(n/2,d*b);
int r=n-xa-xb;
//cout<<d<<" "<<xa<<" "<<" "<<xb<<" "<<r<<endl;
cout<<d*(a+b)+r<<endl;
}
}
}
[CF1303B] National Project - 数学的更多相关文章
- URAL 1614. National Project “Trams” [ 构造 欧拉回路 ]
传送门 1614. National Project “Trams” Time limit: 0.5 secondMemory limit: 64 MB President has declared ...
- URAL 1614. National Project “Trams” (图论大YY)
1614. National Project "Trams" Time limit: 0.5 second Memory limit: 64 MB President has de ...
- Educational Codeforces Round 82 B. National Project
Your company was appointed to lay new asphalt on the highway of length nn. You know that every day y ...
- PMP用语集
AC actual cost 实际成本 ACWP actual cost of work performed 已完工作实际成本 BAC budget at completion 完工预算 BCWP b ...
- [C4] Andrew Ng - Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization
About this Course This course will teach you the "magic" of getting deep learning to work ...
- 初始 vue
1.js,jQuery编程范式:命令式编程 vue编程范式:声明式编程 v-for 遍历数组内容 v-on: click 监听点击事件,语法糖 @click el: 类型:string | H ...
- Educational Codeforces Round 82 (Rated for Div. 2) A-E代码(暂无记录题解)
A. Erasing Zeroes (模拟) #include<bits/stdc++.h> using namespace std; typedef long long ll; ; in ...
- [CF百场计划]#3 Educational Codeforces Round 82 (Rated for Div. 2)
A. Erasing Zeroes Description You are given a string \(s\). Each character is either 0 or 1. You wan ...
- 2021.02.21cf补题
B. National Project 题意:总长度为n的公路进行维修,天气是有规律性的,连续g天的好天气,连续b天的坏天气,必须在好天气进行维护,问至少维护n的一半,那么至少需要多少天 思路:必须是 ...
随机推荐
- ClientAbortException :客户端异常终止
ClientAbortException :客户端异常终止 java.io.IOException: 你的主机中的软件中止了一个已建立的连接. 罪魁祸首: <img src="chec ...
- javascript30--day03--Css Variables
相关视频链接:https://www.bilibili.com/video/av8481988/?p=5 相关github地址:https://github.com/soyaine/JavaScri ...
- 记录 2020年2月26日 java的一次远程技术面试
1. 自我介绍 2.String 类型为什么是final类型?String 为啥不可变? String 类型是final类型原因: 1.不可变性支持线程安全(为了线程安全) 2.不可变性支持字符串常量 ...
- RabbitMQ工作模式
------------恢复内容开始------------ RabbitMQ基本概念: Producer:生产者(消息的提供者) Consumer:消费者(消息的使用者) Message:消息(程序 ...
- oo第三次作业--jml
1.首先我们应该了解什么是jml,jml是java modeling language的缩写,是一种为java规格化设计的标识语言,简单来说,就是描述“干什么”的标准语言(跟注释差不多,但是是标准化注 ...
- CF926B Add Points
一道尚未评定的水题 更好的阅读体验 思路 来分析分析样例: 3 -5 10 5 我们把它升序排列,会得到这个东西↑ 不仔细地观察后可以发现:加一个(0,0)的点显然是最优的 再用脚趾头想想为什么,我们 ...
- mongDb在node中的操作
mongoDb 干嘛的:数据库,nosql(非关系型|缓存型) 场景:解决大规模数据集合多重数据种类 下载:https://www.mongodb.com/download-center 安装:htt ...
- 二次剩余的判定及Cipolla算法
二次剩余 ppp是奇素数.所有的运算都是在群Zp∗Z_{p}^{*}Zp∗中的运算.方程x2=a≠0x^2=a \neq 0x2=a̸=0问是否有解,以及解是什么?若有解,aaa就是模ppp的二次 ...
- 剑指offer-面试题49-丑数-空间换时间
/* 题目: 求从1开始的第n个丑数. */ /* 思路: 按顺序列出各个丑数. */ #include<iostream> #include<cstring> #includ ...
- sql多字段分组排序显示全部数据
建表sql CREATE TABLE `tbl_demo` ( `id` ) COLLATE utf8_bin NOT NULL, `payer_name` ) COLLATE utf8_bin DE ...