spoj SMPDIV - Divisibility

Print all integers ai such that ai is divisible by x and not divisible by y, where 1 < ai < n < 100000.

Input

First, you are given t (t<100) - the number of test cases. In each of the following t lines, 3 integers: n x y.

You might assume also that x < n and x is not divisible by y.

Output

In each of the following t lines, numbers requested in the problem description in the separated by a single space in ascending order.

Example

Input:
2 
7 2 4
35 5 12
Output:
2 6 
5 10 15 20 25 30
比较简单,直接贴代码

import sys
debug = False

if debug:
    stdin = sys.stdin;
    fin = open('f:/oj/uva_in.txt', 'r')
    sys.stdin = fin

t = int(sys.stdin.readline())
while (t > 0):
    line = sys.stdin.readline()
    data = line.strip().split(' ')
    n = int(data[0])
    x = int(data[1])
    y = int(data[2])
    
    first = True
    for i in range(x, n, x):
        if (first):
            first = False
        else:
            print(' ', end='')
            
        if (i % y != 0):
            print(i, end='')
    print()
    
    t = t - 1
    
if debug:
    sys.stdin = stdin             
    



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值