time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Taisia has n� six-sided dice. Each face of the die is marked with a number from 11 to 66, each number from 11 to 66 is used once.
Taisia rolls all n� dice at the same time and gets a sequence of values a1,a2,…,an�1,�2,…,�� (1≤ai≤61≤��≤6), where ai�� is the value on the upper face of the i�-th dice. The sum of this sequence is equal to s�.
Suddenly, Taisia's pet cat steals exactly one dice with maximum value ai�� and calculates the sum of the values on the remaining n−1�−1 dice, which is equal to r�.
You only know the number of dice n� and the values of s�, r�. Restore a possible sequence a� that fulfills the constraints.
Input
The first line contains the integer t� (1≤t≤10001≤�≤1000) — the number of testcases.
Each testcase is given on a separate line and contains three integers n�, s�, r� (2≤n≤502≤�≤50, 1≤r<s≤3001≤�<�≤300).
It is guaranteed that a solution exists.
Output
For each testcase, print: n� integers a1,a2,…,an�1,�2,…,�� in any order. It is guaranteed that such sequence exists.
If there are multiple solutions, print any.
Example
input
Copy文章来源:https://www.toymoban.com/news/detail-495172.html
7
2 2 1
2 4 2
4 9 5
5 17 11
3 15 10
4 4 3
5 20 15
output
Copy
1 1 2 2 1 2 2 4 6 4 2 3 2 5 5 5 1 1 1 1 1 4 5 5 5
解题说明:此题是一道数学题,有 n个色子,它们朝上的面的点数之和为 s,去掉其中一个色子后的和为 r,问原来所有色子的点数。其中有一个棋子为 s − r,则题目转换为求 n − 1个不大于 6的数且和为 r。文章来源地址https://www.toymoban.com/news/detail-495172.html
#include<stdio.h>
#include<string.h>
int main()
{
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++)
{
int n, s, r;
scanf("%d%d%d", &n, &s, &r);
printf("%d ", s - r);
for (int j = 1; j < n; j++)
{
printf("%d ", (r / (n - j)));
r = r - (r / (n - j));
}
printf("\n");
}
return 0;
}
到了这里,关于B. Taisia and Dice的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!