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 you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.
Skipping the repair is necessary because of the climate. The climate in your region is periodical: there are gg days when the weather is good and if you lay new asphalt these days it becomes high-quality pavement; after that, the weather during the next bb days is bad, and if you lay new asphalt these days it becomes low-quality pavement; again gg good days, bb bad days and so on.
You can be sure that you start repairing at the start of a good season, in other words, days 1,2,…,g1,2,…,g are good.
You don't really care about the quality of the highway, you just want to make sure that at least half of the highway will have high-quality pavement. For example, if the n=5n=5 then at least 33 units of the highway should have high quality; if n=4n=4 then at least 22 units should have high quality.
What is the minimum number of days is needed to finish the repair of the whole highway?
The first line contains a single integer TT (1≤T≤1041≤T≤104) — the number of test cases.
Next TT lines contain test cases — one per line. Each line contains three integers nn, gg and bb (1≤n,g,b≤1091≤n,g,b≤109) — the length of the highway and the number of good and bad days respectively.
Print TT integers — one per test case. For each test case, print the minimum number of days required to repair the whole highway if at least half of it should have high quality.
3
5 1 1
8 10 10
1000000 1 1000000
5
8
499999500000
读懂题意多判断几次即可(没有想到更好的解法orz)。因为这有个硬性限制是高质量的路段数必须不少于一半,所以先从这里考虑,求出至少的周期个数,再决定低质量的路段是否需要额外的天数。注意:在高质量路段已经修建完成的情况下,低质量的路段也可以在good days修建。
#include <bits/stdc++.h>
using namespace std;
long long n,g,b;
int main()
{
int t;
cin>>t;
while(t--)
{
scanf("%d%d%d",&n,&g,&b);
long long half;
if(n%==)half=n/;//至少需要完成的高质量的路段数
else half=n/+;
long long res=n-half;//剩余的路段数
int period=;//周期个数
long long ans=;//答案
if(half%g==)//如果要完成的高质量路段数能被g整除
{
period=half/g;
if(res<=b*period)
{
ans=(period-)*(g+b)+g;
if(res<=(period-)*b)
{
}
else
{
ans=res+period*g;
}
}
else
{
ans=res+period*g;
}
}
else
{
period=half/g+;
ans+=(period-)*g+half%g;
if(res<=(period-)*b)ans+=(period-)*b;
else ans+=res;
}
cout<<ans<<endl;
}
return ;
}
Educational Codeforces Round 82 B. National Project的更多相关文章
- 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 ...
- 【题解】Educational Codeforces Round 82
比较菜只有 A ~ E A.Erasing Zeroes 题目描述: 原题面 题目分析: 使得所有的 \(1\) 连续也就是所有的 \(1\) 中间的 \(0\) 全部去掉,也就是可以理解为第一个 \ ...
- Educational Codeforces Round 82 (Rated for Div. 2)
题外话 开始没看懂D题意跳了,发现F题难写又跳回来了.. 语文好差,码力好差 A 判第一个\(1\)跟最后一个\(1\)中\(0\)的个数即可 B 乘乘除除就完事了 C 用并查集判一下联通,每个联通块 ...
- Educational Codeforces Round 82 (Rated for Div. 2)E(DP,序列自动机)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],t[]; int n,m; ][]; ...
- Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)
从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...
- Educational Codeforces Round 82 C. Perfect Keyboard
Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him ...
- Educational Codeforces Round 82 A. Erasing Zeroes
You are given a string ss. Each character is either 0 or 1. You want all 1's in the string to form a ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
随机推荐
- 【游记】CSP-J2019谔谔记
结果果然不能把希望寄托在渺茫的玄学上,实力不够还是不要渴求什么奇迹了. ----2020.2.21记 Day -6 考场就在我市,所以东道主应该运气会好一点吧. Day -1 听说本来准备上的中学准备 ...
- linux服务器上部署springboot项目,并让他持续运行到后台
我们知道在运行springboot 项目只需要java -jar + 项目的war包(jar包)名. 但是只要终端已停止那么服务就会被关闭,也就无法访问到我们的项目了.所以我们可以使用守护进程的方式来 ...
- 使用Eclipse远程调试云服务器上的微信公众项目
云服务器系统:centos 7.3 如何在Eclipse上调试我们在云服务器上的项目呢,下面介绍一下步骤: 1.因为root账号不支持远程调试,首先需要在linux上创建一个新的用户,然后用该用户 ...
- 使用vs进行Nuget打包时的LicenseExpression填写示例参考
新版的nuget包 PackageLicense 这样写 最近编译类库项目的时候发现总是有个 licenseUrl 的警告,警告信息如下: warning NU5125: The 'licenseUr ...
- python"TypeError: 'NoneType' object is not iterable"错误解析
尊重原创博主,原文链接:https://blog.csdn.net/dataspark/article/details/9953225 [解析] 一般是函数返回值为None,并被赋给了多个变量. 实例 ...
- appium---如何判断原生页面和H5页面
目前app中存在越来越多的H5页面了,对于一些做app自动化的测试来说,要求也越来越高,自动化不仅仅要支持原生页面,也要可以H5中进行操作自动化,这一篇介绍如何查看页面上是否存在H5页面,这里首先要了 ...
- buuctf wireshark
首先下载文件夹 然后用wireshark进行分析 然后发现啥也不会然后查一下资料https://www.jianshu.com/p/55ec409c739e 然后根据资料找了tcp然后根据解析做出此题 ...
- Spring一些注解
spring @component的作用详细介绍 1.@controller 控制器(注入服务) 2.@service 服务(注入dao) 3.@repository dao(实现dao访问) 4.@ ...
- Linux双网卡bond、起子接口
适用场景 服务器两张网卡需要做bond,并且bond后网卡需配置不同网段的地址,用于走不同流量,这个时候就可以采用起子接口的方式. 实验场景 设备 服务器:Server_A 核心交换机:Switch_ ...
- 使用node.js实现多人聊天室(socket.io、B/S)
通过B/S架构实现多人聊天,客户端连接服务器,发送信息,服务器接收信息之后返回给客户端. 主要是通过socket.io实现浏览器和服务器之间进行实时,双向和基于事件的通信. socket.io官方文档 ...