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

    ID: 10746 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>数学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 0≤x≤a0 \le x \le a, 0≤y≤b0 \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,b≤1000a, b \le 1000
22 t≤1000t \le 1000 and a=0a = 0
33 1515 t≤1000t \le 1000 and a,b<n≤1000a, b < n \le 1000
44 1010 t≤1000t \le 1000 and a,b≤1000a, b \le 1000
55 1515 t=1t = 1 and n≤1000n \le 1000
66 1010 t≤1000t \le 1000 and n≤1000n \le 1000
77 3030 No special properties

For 100%100\% of the testdata, 1≤t≤1051 \le t \le 10^5, 4≤n≤1094 \le n \le 10^9, and 0≤a,b≤1090 \le a, b \le 10^9.

Translated by ChatGPT 5