当前位置:网站首页>洛谷P7441 Erinnerung
洛谷P7441 Erinnerung
2022-08-11 04:00:00 【CLH_W】
题目背景
我希望,
我们能留下存在过的痕迹,
然后优雅地离去,
无声地消逝。
我回想,
我们共同拥有的那些记忆:
我们随金色的落叶而聚,
又同白色的雪花而去。
或许什么也没有留下,
就要空手而归。
但我不必恐惧,
不需如此匆忙。
因为那些落叶和雪花,
永远地保存着,
我们书写的故事,
和无比珍贵的回忆。
—— lgswdn
题目描述
小 Y 和小 Z 都是生活在 Arcaea Offline 的精灵。小 Y 有无数片落叶,其中第 ii 片落叶的价值为 C_iC
i
。小 Z 有无数片雪花,其中第 ii 片雪花的价值为 E_iE
i
。经过小 X 的仔细观察,他发现 CC 和 EE 满足特殊的条件:
C_i= \begin{cases} x\times i& (x\times i\le K)\ -K& \text{otherwise} \end{cases}
C
i
={
x×i
−K
(x×i≤K)
otherwise
E_i= \begin{cases} y\times i& (y\times i\le K)\ -K& \text{otherwise} \end{cases}
E
i
={
y×i
−K
(y×i≤K)
otherwise
小 Y 和小 Z 可以对这些落叶和雪花进行一些操作。每次,他们会选择满足价值之和 \ge K≥K 的一片落叶和一片雪花,然后让把它们一同组成一段彩色的回忆(Erinnerung)。之后,这片雪花和这片落叶就消失不见了,之后的操作也不能再用到这片雪花和落叶了。
小 X 想知道,他们最多能进行多少次操作。
输入格式
本题有多组数据。
第一行一个整数 TT,表示数据的组数。
接下来 TT 行,每行三个非负整数 x,y,Kx,y,K。
输出格式
对于每组数据,输出一个整数,代表最多能有多少次操作。每组数据的答案用一个换行符隔开。
输入输出样例
输入 #1复制
2
2 3 10
2 4 11
输出 #1复制
3
2
输入 #2复制
1
0 0 1
输出 #2复制
0
说明/提示
【样例解释】
对于样例 1 的第一组数据,落叶的价值为 2,4,6,8,10,-10,-10\dots2,4,6,8,10,−10,−10… ,雪花的价值为 3,6,9,-10,-10\dots3,6,9,−10,−10… 。第一次操作选取第 44 片落叶和第 11 片雪花,价值和为 1111。第二次操作选取第 22 片落叶和第 22 片雪花,价值和为 1010。第三次操作选取第 55 片落叶和第 33 片雪花,价值和为 1919。如是,可以进行 33 次操作。容易证明不存在更优的解。
对于第二组数据,进行的两次操作可以为:选取第 44 片落叶和第 11 片雪花,以及选取第 22 片落叶和第 22 片雪花。
对于样例 2,所有的雪花和落叶的价值都为 00,不可能找到落叶和雪花使其和 \ge 1≥1。
【数据范围】
Subtask 1(30 points):x,y,K,T\le 10x,y,K,T≤10。
Subtask 2(70 points):无特殊限制。
对于 100%100% 的数据,满足 0\le x,y\le 10^{10}0≤x,y≤10
10
,1\le K\le 10^{10}1≤K≤10
10
,1\le T\le 10^51≤T≤10
5
。
上代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
long long x,y,k;
scanf("%lld%lld%lld",&x,&y,&k);
if(x==0||y==0){
//特判0
if(x&&!(k%x))
puts("1");
else if(y&&!(k%y))
puts("1");
else
puts("0");
}
else
printf("%lld\n",k/max(x,y));
}
return 0;
}
边栏推荐
- Read the article, high-performance and predictable data center network
- Basic understanding of MongoDB (2)
- [yu gong series] Go program 035-08 2022 interfaces and inheritance and transformation and empty interface
- Alibaba Cloud releases 3 high-performance computing solutions
- leetCode刷题14天二叉树系列之《 110 平衡二叉树判断》
- Rotary array problem: how to realize the array "overall reverse, internal orderly"?"Three-step conversion method" wonderful array
- Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
- uni-app - 城市选择索引列表 / 通过 A-Z 排序的城市列表(uview 组件库 IndexList 索引列表)
- [ADI low-power 2k code] Based on ADuCM4050, ADXL363, TMP75 acceleration, temperature detection and serial port printing, buzzer playing music (lone warrior)
- App Basic Framework Construction丨Log Management - KLog
猜你喜欢
console.log alternatives you didn't know about
A simple JVM tuning, learn to write it on your resume
EasyCVR接入海康大华设备选择其它集群服务器时,通道ServerID错误该如何解决?
电力机柜数据监测RTU
Rotary array problem: how to realize the array "overall reverse, internal orderly"?"Three-step conversion method" wonderful array
"110 Balanced Binary Tree Judgment" in leetCode's 14-day binary tree series
Homework 8.10 TFTP protocol download function
Graphical LeetCode - 640. Solving Equations (Difficulty: Moderate)
【FPGA】day19-二进制转换为十进制(BCD码)
使用jackson解析json数据详讲
随机推荐
什么是机器强化学习?原理是什么?
Leetcode 669. 修剪二叉搜索树
Common layout effect realization scheme
LeetCode刷题第11天字符串系列之《 58最后一个单词长度》
[FPGA] day19- binary to decimal (BCD code)
EasyCVR接入GB28181设备时,设备接入正常但视频无法播放是什么原因?
【FPGA】day20-I2C读写EEPROM
What are port 80 and port 443?What's the difference?
.NET自定义中间件
Get Qt installation information: including installation directory and various macro addresses
Map中的getOrDefualt方法
js uses the string as the js execution code
使用百度EasyDL实现施工人员安全装备检测
Enter the starting position, the ending position intercepts the linked list
【愚公系列】2022年08月 Go教学课程 035-接口和继承和转换与空接口
【FPGA】SDRAM
Echart地图的省级,以及所有地市级下载与使用
Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
What is Machine Reinforcement Learning?What is the principle?
Detailed explanation of VIT source code