CF1912B.Blueprint for Seating
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
An aircraft manufacturing company wants to optimize their products for passenger airlines. The company's latest research shows that most of the delays happen because of slow boarding.
Most of the medium-sized aircraft are designed with 3-3 seat layout, meaning each row has 6 seats: 3 seats on the left side, a single aisle, and 3 seats on the right side. At each of the left and right sides there is a window seat, a middle seat, and an aisle seat. A passenger that boards an aircraft assigned to an aisle seat takes significantly less time than a passenger assigned to a window seat even when there is no one else in the aircraft.
The company decided to compute an inconvenience of a layout as the total sum of distances from each of the seats of a single row to the closest aisle. The distance from a seat to an aisle is the number of seats between them. For a 3-3 layout, a window seat has a distance of 2, a middle seat — 1, and an aisle seat — 0. The inconvenience of a 3-3 layout is (2+1+0)+(0+1+2)=6. The inconvenience of a 3-5-3 layout is (2+1+0)+(0+1+2+1+0)+(0+1+2)=10.
Formally, a layout is a sequence of positive integers a1,a2,…,ak+1 — group i having ai seats, with k aisles between groups, the i-th aisle being between groups i and i+1. This means that in a layout each aisle must always be between two seats, so no aisle can be next to a window, and no two aisles can be next to each other.
The company decided to design a layout with a row of n seats, k aisles and having the minimum inconvenience possible. Help them find the minimum inconvenience among all layouts of n seats and k aisles, and count the number of such layouts modulo 998244353.
一家飞机制造公司希望为其客运航空公司的产品进行优化。该公司最新的研究表明,大多数航班延误是由于登机速度缓慢造成的。
大多数中型飞机采用 3-3 座位布局,即每排有 6 个座位:左侧 3 个座位、一条中央过道、右侧 3 个座位。在左右两侧,各有一个靠窗座位、一个中间座位和一个靠过道座位。即使飞机上没有其他乘客,被分配到靠过道座位的乘客登机所用时间也显著少于被分配到靠窗座位的乘客。
该公司决定将某一种布局的“不便度”(inconvenience)定义为:该排所有座位到其最近过道的距离之和。其中,座位到过道的距离定义为二者之间相隔的座位数。对于 3-3 布局,靠窗座位的距离为 2,中间座位为 1,靠过道座位为 0;因此 3-3 布局的不便度为 (2+1+0)+(0+1+2)=6。而 3-5-3 布局的不便度为 (2+1+0)+(0+1+2+1+0)+(0+1+2)=10。
形式化地,一种布局是一个正整数序列 a1,a2,…,ak+1,表示共 k+1 个座位组,其中第 i 组含 ai 个座位,且在第 i 组与第 i+1 组之间有一条过道(即共有 k 条过道,第 i 条过道位于第 i 组与第 i+1 组之间)。这意味着:每条过道必须始终位于两个座位之间,因此过道不能紧邻靠窗座位(即首尾组至少含一个座位),且任意两条过道也不能彼此相邻(即任意 ai≥1)。
该公司计划设计一种包含 n 个座位、k 条过道且不便度最小的布局。请你帮助他们求出所有含 n 个座位和 k 条过道的布局中的最小不便度,并计算达到该最小不便度的布局数量(对 998244353 取模)。
输入格式
The first line contains an integer t — the number of test cases you need to solve (1≤t≤105).
For each of the test cases, there is a single line containing n and k — the number of seats, and the number of aisles in a row (2≤n≤109; 1≤k≤105; k<n).
The total sum of k in all t given test cases does not exceed 106.
第一行包含一个整数 t —— 你需要解决的测试用例数量(1≤t≤105)。
对于每个测试用例,有一行包含两个整数 n 和 k —— 分别表示一排座位的数量和过道数量(2≤n≤109;1≤k≤105;k<n)。
所有 t 个测试用例中给出的 k 的总和不超过 106。
输出格式
For each test case print two integers — the minimum inconvenience among all possible layouts, and the number of layouts with the minimum inconvenience modulo 998244353.
对于每个测试用例,输出两个整数——所有可能布局中的最小不便度,以及具有最小不便度的布局数量对 998244353 取模的结果。
输入输出样例
输入#1
8 4 1 3 2 4 2 5 2 6 1 6 2 1000000000 1 9 2
输出#1
2 1 0 1 0 1 1 3 6 1 2 4 249999999500000000 1 6 3
说明/提示
In the last test case of 9 2 the possible layouts with the minimum inconvenience of 6 are 3-4-2, 2-4-3, and 2-5-2.
在测试用例 9 2 的最后一个样例中, inconvenience 值最小(为 6)的可能布局有:3-4-2、2-4-3 和 2-5-2。
输入解题思路,AI测评打分。不知道怎么写?