D. Two Arithmetic Progressions from:http://codeforces.com/contest/710/problem/D
http://www.cnblogs.com/Sunshine-tcf/p/5801347.html