B. Taisia and Dice

这篇具有很好参考价值的文章主要介绍了B. Taisia and Dice。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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

 

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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

    JavaScript 内存不足,指的就是Node,Node 基于V8引擎, Node 中通过script使用的内存只是很小的一部分(64位系统下约为1.4 GB,32位系统下约为0.7 GB),当我们的开发中包比较大时,就容易形成内存不足。 \\\"serve\\\": \\\"node --max_old_space_size=4096 node_modules/@vue/cli-service/bin/vue-cli-service.js serve\\\" 或者

    2024年02月12日
    浏览(39)
  • k8s+arm环境,clickhouse出现多次MEMORY_LIMIT_EXCEEDED导致pod crash

    k8s+arm环境,clickhouse出现多次MEMORY_LIMIT_EXCEEDED导致pod crash,可能是hugepage干扰内存分配器 1、修改文件 2、验证是否关闭

    2024年02月08日
    浏览(31)
  • doris查询报错err: Error 1105: errCode = 2, detailMessage = Memory limit exceeded:<consuming tracker:...

    为了防止用户的一个查询可能因为消耗内存过大。查询进行了内存控制,一个查询任务,在单个 BE 节点上默认使用不超过 2GB 内存。 用户在使用时,如果发现报 Memory limit exceeded 错误,一般是超过内存限制了。 遇到内存超限时,用户应该尽量通过优化自己的 sql 语句来解决。

    2024年02月10日
    浏览(25)
  • FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory(JS stacktrace )

    目录 一、问题 二、原因分析 三、解决方案 1.package.json中配置 2.使用increase-memory-limit插件 往期回顾 我的博客原文:FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory(JS stacktrace ) 我们前端在升级运行自动化运行脚本的时候,linux机器上会报这样一个错误 FATAL E

    2024年03月26日
    浏览(42)
  • 运行代码报错:FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

    一、背景         进公司拉取项目代码,npm install拉取依赖后,运行控制台报错:FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory 二、原因分析         JavaScript heap out of memory说的是 JavaScript 运行内存不足,其实就是Node运行时内存不足。Node 中通过script使用

    2024年02月06日
    浏览(36)
  • FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory node编译时的内存溢出

    报错:FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory 原因:node编译时的内存溢出,因为打包文件过大,刚好超过内存的限制大小造成编译中断。 解决方法1: 解决方法2:(实践过可用) 使用 increase-memory-limit 插件,增加node服务器内存限制

    2024年02月03日
    浏览(31)
  • Solidity内存布局介绍 Layout in Memory and Storage

    Solidity reserves four 32-byte slots, with specific byte ranges (inclusive of endpoints) being used as follows: 0x00 - 0x3f (64 bytes): scratch space(暂存空间) for hashing methods  Hash方法的暂存空间. 0x40 - 0x5f (32 bytes): currently allocated memory size (aka. free memory pointer) 0x60 - 0x7f (32 bytes): zero slot Solidity保留了四个32字节的

    2024年02月16日
    浏览(38)
  • ARMv8内存属性与类型(Memory types and attributes)简介

    ARMv8中将内存分为两种类型:Normal memory和Device memory,Normal memory适用于系统中的大部分内存,而Device memory则适用于外设所使用的内存。 目录 1,Normal Memory 1.1 Shareable Normal Memory 1.1.1 Inner Shareable, and Outer Shareable属性 1.2 Non-shareable Normal memory 1.3 Cacheability attributes for Normal memory 2,

    2024年02月08日
    浏览(33)
  • RuntimeError: CUDA out of memory See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

    报错: If reserved memory is allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF 当reserved memory is allocated memory,进行如下设置,可解决此bug: 代码如下:

    2024年02月11日
    浏览(42)
  • Linux 内存模型(Memory: the flat, the discontiguous, and the sparse)

    计算机系统中的物理内存是一种宝贵的资源,因此人们付出了大量的努力来有效地管理它。由于现代系统上存储器体系结构的复杂性,这项任务变得更加困难。有几个抽象层处理如何布局物理内存的细节;其中一个简单地称为“内存模型”。内核中支持三个模型,但其中一个

    2024年02月14日
    浏览(30)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包