您的位置:首页 > 其它

[hackerrank]Manasa and Stones

2014-08-15 20:22 169 查看
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;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: