A11246 | Eleventh Birthday
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
It is Borya's eleventh birthday, and he has got a great present: $n$ cards with numbers. The $i$ -th card has the number $a_{i}$ written on it. Borya wants to put his cards in a row to get one greater number. For example, if Borya has cards with numbers $1$ , $31$ , and $12$ , and he puts them in a row in this order, he would get a number $13112$ .
He is only 11, but he already knows that there are $n!$ ways to put his cards in a row. But today is a special day, so he is only interested in such ways that the resulting big number is divisible by eleven. So, the way from the previous paragraph is good, because $13112=1192×11$ , but if he puts the cards in the following order: $31$ , $1$ , $12$ , he would get a number $31112$ , it is not divisible by $11$ , so this way is not good for Borya. Help Borya to find out how many good ways to put the cards are there.
Borya considers all cards different, even if some of them contain the same number. For example, if Borya has two cards with 1 on it, there are two good ways.
Help Borya, find the number of good ways to put the cards. This number can be large, so output it modulo $998244353$ .
He is only 11, but he already knows that there are $n!$ ways to put his cards in a row. But today is a special day, so he is only interested in such ways that the resulting big number is divisible by eleven. So, the way from the previous paragraph is good, because $13112=1192×11$ , but if he puts the cards in the following order: $31$ , $1$ , $12$ , he would get a number $31112$ , it is not divisible by $11$ , so this way is not good for Borya. Help Borya to find out how many good ways to put the cards are there.
Borya considers all cards different, even if some of them contain the same number. For example, if Borya has two cards with 1 on it, there are two good ways.
Help Borya, find the number of good ways to put the cards. This number can be large, so output it modulo $998244353$ .
输入格式
Input data contains multiple test cases. The first line of the input data contains an integer $t$ — the number of test cases ( $1<=t<=100$ ). The descriptions of test cases follow.
Each test is described by two lines.
The first line contains an integer $n$ ( $1<=n<=2000$ ) — the number of cards in Borya's present.
The second line contains $n$ integers $a_{i}$ ( $1<=a_{i}<=10^{9}$ ) — numbers written on the cards.
It is guaranteed that the total number of cards in all tests of one input data doesn't exceed $2000$ .
Each test is described by two lines.
The first line contains an integer $n$ ( $1<=n<=2000$ ) — the number of cards in Borya's present.
The second line contains $n$ integers $a_{i}$ ( $1<=a_{i}<=10^{9}$ ) — numbers written on the cards.
It is guaranteed that the total number of cards in all tests of one input data doesn't exceed $2000$ .
输出格式
For each test case output one line: the number of ways to put the cards to the table so that the resulting big number was divisible by 11, print the number modulo $998244353$ .
输入输出样例
输入 #1
4 2 1 1 3 1 31 12 3 12345 67 84 9 1 2 3 4 5 6 7 8 9
输出 #1
2 2 2 31680
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted