当前位置:网站首页>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;
}
边栏推荐
- Talk about the design and implementation logic of payment process
- [mathematical logic] equivalent calculus and reasoning calculus of predicate logic (individual word | predicate | quantifier | predicate logic formula | two basic formulas | proposition symbolization
- Interviewer: why is the value nil not equal to nil?
- [combinatorics] recursive equation (summary of the solution process of recursive equation | homogeneous | double root | non-homogeneous | characteristic root is 1 | exponential form | the bottom is th
- The difference between i++ and ++i: tell their differences easily
- How to read the source code [debug and observe the source code]
- Records of long objects and long judgments in the stream of list
- Brief introduction to the core functions of automatic penetration testing tool
- Kotlin的協程:上下文
- How to deploy applications on kubernetes cluster
猜你喜欢
STM32 realizes 74HC595 control
Codeforces Round #803 (Div. 2) C. 3SUM Closure
微服务组件Sentinel控制台调用
The third day of writing C language by Yabo people
Classroom attendance system based on face recognition tkinter+openpyxl+face_ recognition
Wechat applet for the first time
聊聊支付流程的设计与实现逻辑
Hongmeng third training
TensorBoard快速入门(Pytorch使用TensorBoard)
QT学习日记9——对话框
随机推荐
List of financial products in 2022
Redis core technology and practice - learning notes (11): why not just string
Leetcode 669 pruning binary search tree -- recursive method and iterative method
Draw some simple graphics with MFC
A. Odd Selection【BruteForce】
[combinatorics] generating function (shift property)
PHP returns 500 errors but no error log - PHP return 500 error but no error log
PHP MySQL create database
The gbase 8A database does not support the DB2 function value (column_name, 0) cluster syntax
Deops入门
Fedora 21 installs lamp host server
How to enforce parameters in PowerShell- How do I make parameters mandatory in PowerShell?
Golang unit test, mock test and benchmark test
聊聊支付流程的设计与实现逻辑
[combinatorics] recursive equation (case where the non-homogeneous part is exponential | example where the non-homogeneous part is exponential)
Enterprise custom form engine solution (XI) -- form rule engine 1
PUT vs. POST for Uploading Files - RESTful API to be Built Using Zend Framework
Analysis report on production and marketing demand and investment forecast of China's PVC industry from 2021 to 2026
微服务组件Sentinel控制台调用
国内如何购买Google Colab会员