#P10090. [ROIR 2022] 幼儿园的新年 (Day 2)

    ID: 10746 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学2022Special JudgeROIR(俄罗斯)

[ROIR 2022] 幼儿园的新年 (Day 2)

Background

Translated and simplified from ROIR 2022 D2T1.

Problem Description

Given three integers n,a,bn, a, b, find how many pairs (x,y)(x, y) satisfy 0xa0 \le x \le a, 0yb0 \le y \le b, x+yx + y is not 00, and x+yx + y is divisible by nn.

Input Format

This problem has multiple test cases. The first line contains an integer tt, representing the number of test cases.

The next tt lines each contain one test case: n,a,bn, a, b, separated by spaces.

Output Format

For each test case, output one number per line, which is the number of valid (x,y)(x, y) pairs.

4
4 2 2
4 4 4
6 5 5
8 13 17
1
6
5
30

Hint

This problem uses bundled testdata.

Subtask Points Special Properties
11 1010 t=1t = 1 and a,b1000a, b \le 1000
22 t1000t \le 1000 and a=0a = 0
33 1515 t1000t \le 1000 and a,b<n1000a, b < n \le 1000
44 1010 t1000t \le 1000 and a,b1000a, b \le 1000
55 1515 t=1t = 1 and n1000n \le 1000
66 1010 t1000t \le 1000 and n1000n \le 1000
77 3030 No special properties

For 100%100\% of the testdata, 1t1051 \le t \le 10^5, 4n1094 \le n \le 10^9, and 0a,b1090 \le a, b \le 10^9.

Translated by ChatGPT 5