AT_arc221_a.Two Arithmetic Progressions
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given positive integers N,A,B,C,D.
Find i=1∑Ngcd(Ai+B,Ci+D), modulo 998244353. Here, gcd(x,y) denotes the greatest common divisor of x and y.
You are given T test cases; solve each of them.
给定正整数 N,A,B,C,D。
求 i=1∑Ngcd(Ai+B,Ci+D) 对 998244353 取模的值。其中,gcd(x,y) 表示 x 与 y 的最大公约数。
你将得到 T 组测试用例;请分别求解每一组。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N A B C D
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例按以下格式给出:
N A B C D
输出格式
Output the answers for the test cases in order, separated by newlines.
按顺序输出测试用例的答案,答案之间用换行符分隔。
输入输出样例
输入#1
3 4 1 3 4 2 100000000 1 1 1 2 100000000 1 1 1 1
输出#1
10 100000000 822404071
说明/提示
Sample 1 Explanation:
For the first test case, the answer is gcd(4,6)+gcd(5,10)+gcd(6,14)+gcd(7,18)=2+5+2+1=10.
Constraints
- 1≤T≤200
- 1≤N≤109
- 1≤A,B,C,D≤104
- All input values are integers.
样例 1 解释:
对于第一个测试用例,答案为 gcd(4,6)+gcd(5,10)+gcd(6,14)+gcd(7,18)=2+5+2+1=10。
约束条件
- 1≤T≤200
- 1≤N≤109
- 1≤A,B,C,D≤104
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?