当前位置:网站首页>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;
}
边栏推荐
- BFS - topology sort
- How to read the source code [debug and observe the source code]
- Baiwen.com 7 days Internet of things smart home learning experience punch in the next day
- 数学公式(测试)
- [combinatorics] recursive equation (special solution example 1 Hannover tower complete solution process | special solution example 2 special solution processing when the characteristic root is 1)
- AcWing 4489. Longest subsequence
- [教程]在 CoreOS 上构建你的第一个应用
- Graduation summary
- c# . Net tool ecosystem
- Keepalived setting does not preempt resources
猜你喜欢
Global and Chinese health care OEM and ODM market status survey and investment planning recommendations report 2022-2028
Records of long objects and long judgments in the stream of list
Redis core technology and practice - learning notes (IX): slicing cluster
1164 Good in C
List的stream中Long对象与long判等问题记录
Talk about the design and implementation logic of payment process
Leetcode 108 converts an ordered array into a binary search tree -- recursive method
Embedded-c language-7
1147_ Makefile learning_ Target files and dependent files in makefile
TensorBoard快速入门(Pytorch使用TensorBoard)
随机推荐
WebView module manages the application window interface to realize the logical control and management operation of multiple windows (Part 1)
Inheritance of ES6 class
Assembly for unloading Loadfrom() loaded assembly - unloading the assembly loaded with assembly LoadFrom()
link preload prefetch
Hongmeng third training
Fedora 21 安装 LAMP 主机服务器
PHP MySQL inserts multiple pieces of data
面试官:值为 nil 为什么不等于 nil ?
The difference between i++ and ++i: tell their differences easily
Golang unit test, mock test and benchmark test
Redis core technology and practice - learning notes (VII) sentinel mechanism
List of financial products in 2022
Web-ui automated testing - the most complete element positioning method
PHP returns 500 errors but no error log - PHP return 500 error but no error log
Research Report on investment trends and development planning of China's thermal insulation material industry, 2022-2028
Introduction to SolidWorks gear design software tool geartrax
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
Enterprise custom form engine solution (XI) -- form rule engine 1
PHP MySQL create database
小程序 多tab 多swiper + 每个tab分页