- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# C++ code to find different winner and non-winner counts on a contest

Suppose we have two numbers n and k, There are n students in a contest. Some of them will receive memento, some will get certificates, and others won't receive anything. Who receives something are called winners. But there are some rules of counting the number of memento and certificates. The number of certificates must be exactly k times greater than the number of memento. The number of winners must not be greater than n/2. It's also possible that there are no winners. We have to identify the maximum possible number of winners, according to these rules. Then find the number of students with memento, the number of students with certificates and the number of students who are not winners.

So, if the input is like n = 18; k = 2, then the output will be [3, 6, 9].

## Steps

To solve this, we will follow these steps −

x := (n / 2) / (1 + k) return x, (k * x) and (n - (x + (k * x)))

## Example

Let us see the following implementation to get better understanding −

#include <bits/stdc++.h> using namespace std; void solve(int n, int k){ int x = (n / 2) / (1 + k); cout << x << ", " << (k * x) << ", " << (n - (x + (k * x))); } int main(){ int n = 18; int k = 2; solve(n, k); }

## Input

8, 2

## Output

3, 6, 9

- Related Questions & Answers
- C++ code to find winner of math contest
- C++ program to find winner of card game
- Program to find winner of stone game in Python
- C++ program to find winner of cell coloring game
- C++ program to find winner of ball removal game
- C++ Program to find winner of unique bidding game
- C++ code to check water pouring game has all winner or not
- Program to find winner of a rower reducing game in Python
- Program to find winner of a rower breaking game in Python
- Predict the Winner in C++
- Python program to find score and name of winner of minion game
- C++ Program to find winner and final price in a second price auction event
- Program to find winner of array removal game in Python
- Program to find winner of number reducing game in Python
- C++ Program to find winner name of stick crossing game