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走一波!!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

做一个AC梦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值