119. Magic Pairs



119. Magic Pairs

time limit per test: 0.25 sec.
memory limit per test: 4096 KB

“Prove that for any integer X and Y if 5X+4Y is divided by 23 then 3X+7Y is divided by 23 too.” The task is from city Olympiad in mathematics in Saratov, Russia for schoolchildren of 8-th form. 2001-2002 year.


For given N and pair (A0, B0) find all pairs (A, B) such that for any integerX and Y if A0X+B0Y is divided byN then AX+BY is divided by N too (0<=A,B<N).

Input

Each input consists of positive integer numbers N, A0 and B0 (N,A0,B0£ 10000)separated by whitespaces.

Output

Write number of pairs (A, B) to the first line of output. Write each pair on a single line in order of non-descreasingA (and B in case of equal A). Separate numbers by single space.

Sample Input

3
1 2

Sample Output

3 
0 0
1 2
2 1

给出A0,B0,和N。求出所有A,B使得对于任意整数X,Y。如果A0*X+B0*Y能被N整除,那么A*X+B*Y也能被N整除


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值