当前位置:网站首页>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;
}
边栏推荐
- [combinatorics] generating function (shift property)
- Talk about the design and implementation logic of payment process
- Five problems of database operation in commodity supermarket system
- Gear2021 monthly update - December
- Investigation on the operation prospect of the global and Chinese Anti enkephalinase market and analysis report on the investment strategy of the 14th five year plan 2022-2028
- WEB-UI自动化测试-最全元素定位方法
- Kotlin的協程:上下文
- STM32实现74HC595控制
- ArrayList analysis 3: delete elements
- Embedded-c language-7
猜你喜欢
Embedded-c language-7
AcWing 271. 杨老师的照相排列【多维DP】
Tensorboard quick start (pytoch uses tensorboard)
模块九作业
Automata and automatic line of non-standard design
Notes on problems -- watching videos on edge will make the screen green
聊聊支付流程的设计与实现逻辑
微服务组件Sentinel控制台调用
Redis core technology and practice - learning notes (VII) sentinel mechanism
[combinatorics] generating function (summation property)
随机推荐
[combinatorics] generating function (shift property)
Hongmeng third training
SSL / bio pour OpenSSL Get FD
Redis core technology and practice - learning notes (VIII) sentinel cluster: sentinel hung up
Create a new file from templates with bash script - create new file from templates with bash script
ES6类的继承
Tensorboard quick start (pytoch uses tensorboard)
AcWing 4489. Longest subsequence
MySQL grouping query
Type conversion, variable
小程序 多tab 多swiper + 每个tab分页
AcWing 3438. Number system conversion
PHP MySQL where clause
OpenSSL的SSL/BIO_get_fd
Codeforces Round #803 (Div. 2) C. 3SUM Closure
Write a program to process a list container of string type. Find a special value in the container 9.27: and delete it if found. Rewrite the above procedure with deque container.
Talk about the design and implementation logic of payment process
Redis core technology and practice - learning notes (IX): slicing cluster
Inheritance of ES6 class
Discussion sur la logique de conception et de mise en oeuvre du processus de paiement