Problems
| # | Name | ||
|---|---|---|---|
| A |
standard input/output
1 s, 256 MB |
||
| B |
standard input/output
1 s, 256 MB |
||
| C |
standard input/output
1 s, 256 MB |
||
| D |
standard input/output
2 s, 256 MB |
||
| E |
standard input/output
2 s, 256 MB |
以后cf的题能用python写的我就python了,因为以后没正式比赛参加了,不必特地用C++。python写得快,也容易看得懂,我最近也比较需要练习这个。当然有的题C++写得少我还是用C++。
A. Infinite Sequence
题意:给出a,b,c,求是否a加若干个c能得到b,是就输出YES,否就输出NO
题解:
就特判各种情况,一般情况是看(b-a)%c==0
特殊情况,依次判断:
1.a==b,YES
2.c==0,NO
3.b-a与c不同号,NO
4.c小于零,则把b-a和c都变正数再判。
1 def gank(a,b,c): 2 d = b - a 3 if(d==0): 4 return True 5 if(c==0): 6 return False 7 if((d<0 and c>0) or(c<0 and d>0)): 8 return False 9 if(c<0): 10 d*=-1 11 c*=-1 12 if(d%c==0): 13 return True 14 else: 15 return False 16 17 a,b,c = map(int , raw_input().split(' ')) 18 if(gank(a,b,c)): 19 print "YES" 20 else: 21 print "NO"