[hackerrank]Manasa and Stones
https://www.hackerrank.com/contests/w2/challenges/manasa-and-stones
简单题。
#include<iostream> using namespace std; int main() { int T; cin >> T; while (T--) { int n, a, b; cin >> n >> a >> b; // a < b if ( a > b) { int tmp = a; a = b; b = tmp; } int last = 0; for (int i = 0; i < n; i++) { int x = i * b + (n - i - 1) * a; if (x != last) { last = x; cout << x << " "; } } cout << endl; } return 0; }