当前位置:网站首页>洛谷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;
}
边栏推荐
- 机器学习怎么学?机器学习流程
- Alibaba Cloud releases 3 high-performance computing solutions
- Uni - app - access to Chinese characters, pinyin initials (according to the Chinese get pinyin initials)
- 【FPGA】day21- moving average filter
- 获取Qt的安装信息:包括安装目录及各种宏地址
- How can users overcome emotional issues in programmatic trading?
- Interchangeability Measurements and Techniques - Calculation of Deviations and Tolerances, Drawing of Tolerance Charts, Selection of Fits and Tolerance Classes
- Leetcode 450. 删除二叉搜索树中的节点
- 你不知道的 console.log 替代品
- Design and Realization of Employment Management System in Colleges and Universities
猜你喜欢

Is Redis old?Performance comparison between Redis and Dragonfly

es-head plugin insert query and conditional query (5)

STC8H开发(十五): GPIO驱动Ci24R1无线模块

使用jackson解析json数据详讲

"110 Balanced Binary Tree Judgment" in leetCode's 14-day binary tree series

Interchangeability and Measurement Technology—Surface Roughness Selection and Marking Method

多串口RS485工业网关BL110

Use jackson to parse json data in detail

es-head插件插入查询以及条件查询(五)

一文读懂 高性能可预期数据中心网络
随机推荐
阿里云发布3大高性能计算解决方案
.NET Custom Middleware
高校就业管理系统设计与实现
es-head plugin insert query and conditional query (5)
机器学习是什么?详解机器学习概念
A simple JVM tuning, learn to write it on your resume
机器学习可以应用在哪些场景?机器学习有什么用?
Differences and connections between distributed and clustered
Leetcode 669. 修剪二叉搜索树
What is machine learning?Explain machine learning concepts in detail
如何进行AI业务诊断,快速识别降本提效增长点?
【C语言】入门
Audio codec, using FAAC to implement AAC encoding
Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
The development of the massage chair control panel makes the massage chair simple and intelligent
LeetCode刷题第12天二叉树系列之《104 二叉树的最大深度》
MYSQLg高级------回表
使用jackson解析json数据详讲
What is Machine Reinforcement Learning?What is the principle?
Homework 8.10 TFTP protocol download function