AT_arc222_d.Shift and Add
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Define the digit sum of a non-negative integer n as the sum of the digits when n is written in decimal notation. For example, the digit sum of 2026 is 2+0+2+6=10.
You are given positive integer sequences A=(A1,A2,…,AN) and B=(B1,B2,…,BN).
Using A and B, define an integer sequence X=(X0,X1,X2,…,XN) as follows:
- Set X0=0.
- For each i=1,2,…,N, choose one of Xi=10Xi−1+Ai and Xi=10Xi−1+Bi to determine Xi.
For each k=1,2,…,N, find the minimum possible digit sum of Xk.
Solve independently for each k. That is, for different k, the way to determine the integer sequence X that minimizes the digit sum of Xk may be different.
定义一个非负整数 n 的数位和为 n 在十进制表示下各位数字之和。例如,2026 的数位和为 2+0+2+6=10。
给定两个正整数序列 A=(A1,A2,…,AN) 和 B=(B1,B2,…,BN)。
利用 A 和 B,定义一个整数序列 X=(X0,X1,X2,…,XN),方式如下:
- 令 X0=0;
- 对每个 i=1,2,…,N,从 Xi=10Xi−1+Ai 与 Xi=10Xi−1+Bi 中任选其一来确定 Xi。
对每个 k=1,2,…,N,求 Xk 的最小可能数位和。
对每个 k 独立求解。即:对不同的 k,使 Xk 的数位和最小的序列 X 的构造方式可以不同。
输入格式
The input is given from Standard Input in the following format:
N
A1 A2 … AN
B1 B2 … BN
输入从标准输入以如下格式给出:
N
A1 A2 … AN
B1 B2 … BN
输出格式
For k=1,2,…,N, output the minimum possible digit sum of Xk, space-separated.
对于 k=1,2,…,N,输出 Xk 的最小可能各位数字之和,以空格分隔。
输入输出样例
输入#1
2 123 444 456 222
输出#1
6 9
输入#2
15 47640 28384 12457 87254 35032 27915 72870 32688 59091 95771 44037 44252 82222 87110 45829 41522 28795 85247 87801 45150 79509 15308 17923 75921 14992 71984 7601 42312 98436 36545
输出#2
14 18 26 19 28 33 28 34 29 27 29 39 35 43 41
说明/提示
Sample 1 Explanation:
The possible integer sequences X=(X0,X1,X2) are the following four:
- X=(0,123,1674)
- X=(0,123,1452)
- X=(0,456,5004)
- X=(0,456,4782)
The minimum possible digit sum of X1 is 6, which is the digit sum of 123.
The minimum possible digit sum of X2 is 9, which is the digit sum of 5004.
Constraints
- 1≤N≤20000
- 1≤Ai≤109−1
- 1≤Bi≤109−1
- All input values are integers.
样例 1 解释:
可能的整数序列 X=(X0,X1,X2) 共有以下四种:
- X=(0,123,1674)
- X=(0,123,1452)
- X=(0,456,5004)
- X=(0,456,4782)
X1 的最小可能各位数字之和为 6,即 123 的各位数字之和。
X2 的最小可能各位数字之和为 9,即 5004 的各位数字之和。
约束条件
- 1≤N≤20000
- 1≤Ai≤109−1
- 1≤Bi≤109−1
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?