Kattis-Arrangement

Posted 做一个AC梦

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kattis-Arrangement相关的知识,希望对你有一定的参考价值。

题目所述基本内容

One of the things that programming competition organizers have to do is decide which team should be in which room. There are N rooms and M teams. The rooms are similar in size, so it is best for teams to be divided into rooms as evenly as possible. For example, if there are N=3 rooms and M=8 teams, then it is best to put 3 teams in one room, 3 teams in another room, and then the last 2 teams in the last room.

输入输出样例

Input

The input consists of two lines. On the first line is an integer N, and on the second line is an integer M.

Output

The output should contain N lines, one for each room. If k teams are to be in room number i, then line i should contain k copies of the * symbol.

Explanation of sample cases

The first sample is N=1 rooms and M=5 teams. Since there is only one room, all the teams are in that room.

The second sample is the same as the one taken above.

In the third sample, there are N=5 lounges and M=33 teams. Here it is best to put 6 teams in two of the rooms, and 7 teams in the other three rooms. Here we also see that order does not matter.

Scoring

Your solution will be tested on different input data, which is divided into groups as shown in the table below. The solution will then receive points depending on which groups are solved.

Group

Points

Input size

Other conditions

1

20

N=1, M≤500

2

20

N=2, M≤500

3

30

N≤10, M≤500

There will be the same number in each room.

4

30

N≤10, M≤500

代码

#include<iostream>
using namespace std;

int main() 
	int n, m;
	cin >> n >> m;
	int a = m/n;
	int b = m%n;
	for (int i = 0; i < n; i++) 
		if (b > 0) 
			a = a + 1;
			b--;
		
		for (int j = 0; j < a; j++) 
				cout << "*";
			
		a = m / n;
		cout << endl;
		

结束语

好兄弟好兄弟,留下你的关注和点赞,666走一波!!!!!

以上是关于Kattis-Arrangement的主要内容,如果未能解决你的问题,请参考以下文章

Kattis-Arrangement

关于基础微积分的结束语

关于基础微积分的结束语

关于基础微积分的结束语

关于基础微积分的结束语

youcans 的 OpenCV 例程200篇结束语