#P8753. [蓝桥杯 2021 省 AB2] 小平方
[蓝桥杯 2021 省 AB2] 小平方
Problem Description
Xiaolan found that, for a positive integer and a positive integer less than , after squaring and taking it modulo , the result may be less than half of , or it may be greater than or equal to half of .
Ask: among the integers from to , how many numbers have a remainder less than half of when their squares are divided by .
For example, when , the remainders of divided by are all less than half of .
Another example: when , the remainders of and divided by are both , which is less than half of . But the remainders of and divided by are both , which is greater than or equal to half of .
Input Format
The input contains one line with an integer .
Output Format
Output one integer, the number of integers that satisfy the condition.
5
2
Hint
For all test cases, .
Lanqiao Cup 2021 Round 2 Provincial Contest, Group A Problem F (Group B Problem G).
Translated by ChatGPT 5