当前位置:网站首页>A. Berland Poker & 1000 [simple mathematical thinking]
A. Berland Poker & 1000 [simple mathematical thinking]
2022-07-03 17:53:00 【Codiplay】
Title Description :
n There is m A king , altogether k Play cards alone . Everyone takes it n/k card ( Guaranteed Division ), Maximize the difference between the largest and the second largest ( Refined )
Wrong thinking :
Put an end to it :if.... Output an answer ;if...... Output the answer
Positive solution :
Solve it like a math problem , If you want to get the answer , What elements do I need ? For these elements, break them one by one .
Actually Maximize the difference between the largest and the second largest Such refinement can already help me solve problems .
The maximum value can be set directly , Or m, Or n / k. The maximum value is less than or equal to both , So take min.
When the maximum value is determined , Second largest value isomorphism , There is one Round up The operation of .
int theirs = (m - our + k - 2) / (k - 1);// On whom to round , Add denominator -1#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
cin >> t;
while(t -- ){
int n, m, k;
cin >> n >> m >> k;
int our = min(n / k, m);
int thiers = (m - our) / (k - 1);
// Rounding up manually
if((m - our) % (k - 1) != 0) {
thiers ++;
}
cout << our - thiers << '\n';
}
return 0;
}边栏推荐
- 【统信UOS】扫描仪设备管理驱动安装
- Comparison of kotlin collaboration + retro build network request schemes
- 模块九作业
- Research Report on market demand and investment planning for the development of China's office chair industry, 2022-2028
- Ml (machine learning) softmax function to realize the classification of simple movie categories
- Talk about the design and implementation logic of payment process
- (8) HS corner detection
- Internet Hospital his Management Platform source, online Inquiry, appointment Registration Smart Hospital Small program source
- STM32实现74HC595控制
- SSL / bio pour OpenSSL Get FD
猜你喜欢

MySQL has been stopped in the configuration interface during installation

Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
![How to read the source code [debug and observe the source code]](/img/40/a2fca67bcde3c468a739c6990325f4.jpg)
How to read the source code [debug and observe the source code]

(9) Opencv Canny edge detection

互联网医院HIS管理平台源码,在线问诊,预约挂号 智慧医院小程序源码

Vs2013 has blocked the installer, and ie10 needs to be installed

As soon as we enter "remote", we will never regret, and several people will be happy and several people will be sad| Community essay solicitation

BFS - topology sort

PHP MySQL inserts multiple pieces of data

TCP congestion control details | 3 design space
随机推荐
How to enforce parameters in PowerShell- How do I make parameters mandatory in PowerShell?
Automata and automatic line of non-standard design
解决Zabbix用snmp监控网络流量不准的问题
MySQL grouping query
Hongmeng third training
Deops入门
TCP拥塞控制详解 | 3. 设计空间
Assembly for unloading Loadfrom() loaded assembly - unloading the assembly loaded with assembly LoadFrom()
Type conversion, variable
[LINUX]CentOS 7 安装MYSQL时报错“No package mysql-server available“No package zabbix-server-mysql availabl
STM32实现74HC595控制
Keepalived 设置不抢占资源
Introduction to SolidWorks gear design software tool geartrax
Web-ui automated testing - the most complete element positioning method
毕业总结
[mathematical logic] equivalent calculus and reasoning calculus of predicate logic (individual word | predicate | quantifier | predicate logic formula | two basic formulas | proposition symbolization
Create a new file from templates with bash script - create new file from templates with bash script
Interviewer: why is the value nil not equal to nil?
PHP MySQL Update
小程序 多tab 多swiper + 每个tab分页