当前位置:网站首页>洛谷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;
}
边栏推荐
- Callable实现多线程
- "110 Balanced Binary Tree Judgment" in leetCode's 14-day binary tree series
- Docker 链接sqlserver时出现en-us is an invalid culture错误解决方案
- 荣威imax8ev魔方电池安全感,背后隐藏着哪些黑化膨胀?
- MYSQLg advanced ------ return table
- LeetCode刷题第17天之《3 无重复字符的最长子串》
- "104 Maximum Depth of Binary Trees" in LeetCode's Day 12 Binary Tree Series
- 【FPGA】abbreviation
- Get the length of the linked list
- Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
猜你喜欢

Basic understanding of MongoDB (2)

你不知道的 console.log 替代品

EasyCVR接入GB28181设备时,设备接入正常但视频无法播放是什么原因?

【FPGA】day18-ds18b20实现温度采集
![[FPGA] day19- binary to decimal (BCD code)](/img/d8/6d223e5e81786335a143f135385b08.png)
[FPGA] day19- binary to decimal (BCD code)

A simple JVM tuning, learn to write it on your resume

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

【FPGA】day22-SPI协议回环

【愚公系列】2022年08月 Go教学课程 035-接口和继承和转换与空接口

What should I do if the channel ServerID is incorrect when EasyCVR is connected to a Hikvision Dahua device and selects another cluster server?
随机推荐
AI+医疗:使用神经网络进行医学影像识别分析
What is Machine Reinforcement Learning?What is the principle?
Audio codec, using FAAC to implement AAC encoding
"104 Maximum Depth of Binary Trees" in LeetCode's Day 12 Binary Tree Series
Enter the starting position, the ending position intercepts the linked list
DNS separation resolution and intelligent resolution
The solution to the height collapse problem
es-head plugin insert query and conditional query (5)
"3 Longest Substring Without Repeating Characters" on the 17th day of LeetCode brushing
App基本框架搭建丨日志管理 - KLog
【FPGA】day18-ds18b20实现温度采集
What kind of programming trading strategy types can be divided into?
What is machine learning?Explain machine learning concepts in detail
【FPGA】day22-SPI protocol loopback
【深度学习】基于卷积神经网络的天气识别训练
How to delete statements audit log?
Echart地图的省级,以及所有地市级下载与使用
UNI-APP_iphone bottom safe area
2022-08-10 The sixth group Hiding spring study notes
使用百度EasyDL实现施工人员安全装备检测