AT_abc460_e.x + y ≡ x + y
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
For positive integers a and b, define concat(a,b) as the integer formed by writing a and b one after another. More formally, concat(a,b) is defined as follows.
- Let A and B be the strings formed by writing a and b in decimal, respectively. Let C be the string formed by concatenating A and B in this order. The value of C interpreted as an integer in decimal notation is concat(a,b).
For example, if a=123 and b=45, then concat(a,b)=12345.
You are given positive integers N and M.
Find the number, modulo 998244353, of pairs (x,y) of positive integers not greater than N such that concat(x,y)≡x+y(modM).
You are given T test cases; solve each one.
对于正整数 a 和 b,定义 concat(a,b) 为将 a 和 b 按顺序拼接后所得的整数。更形式化地,concat(a,b) 定义如下:
- 设 A 和 B 分别为 a 和 b 的十进制表示所构成的字符串;令 C 为按此顺序拼接 A 和 B 所得的字符串;则将 C 视为十进制整数所得的值即为 concat(a,b)。
例如,若 a=123、b=45,则 concat(a,b)=12345。
给定正整数 N 和 M,
求满足 1≤x,y≤N 且 concat(x,y)≡x+y(modM) 的正整数对 (x,y) 的个数(对 998244353 取模)。
共给出 T 组测试用例,请对每组分别求解。
输入格式
The input is given from Standard Input in the following format, where casei denotes the i-th test case:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N M
输入从标准输入给出,格式如下,其中 casei 表示第 i 个测试用例:
T
case1
case2
⋮
caseT
每个测试用例的格式如下:
N M
输出格式
Output T lines. The i-th line should contain the answer for the i-th test case.
For each test case, output the number, modulo 998244353, of pairs (x,y) satisfying the condition.
输出 T 行。第 i 行应包含第 i 个测试用例的答案。
对于每个测试用例,输出满足条件的数对 (x,y) 的个数对 998244353 取模的结果。
输入输出样例
输入#1
4 3 2 123 456 20260530 460 123456789123456789 998244353
输出#1
3 0 922576091 422081792
说明/提示
Sample 1 Explanation:
For the first test case, three pairs (x,y) satisfy the condition: (2,1),(2,2),(2,3).
Constraints
- 1≤T≤104
- 1≤N≤1018
- 2≤M≤109
- All input values are integers.
样例 1 解释:
对于第一个测试用例,共有三对 (x,y) 满足条件:(2,1),(2,2),(2,3)。
限制条件
- 1≤T≤104
- 1≤N≤1018
- 2≤M≤109
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?