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;
}

  

[hackerrank]Manasa and Stones的更多相关文章

  1. 【HackerRank】Manasa and Stones

    Change language : Manasa 和 她的朋友出去徒步旅行.她发现一条小河里边顺序排列着带有数值的石头.她开始沿河而走,发现相邻两个石头上的数值增加 a 或者 b. 这条小河的尽头有一 ...

  2. HackerRank "Manasa and Prime game"

    Intuitive one to learn about Grundy basic :) Now every pile becomes a game, so we need to use Spragu ...

  3. Manasa and Stones

    from __future__ import print_function def main(): t = int(raw_input()) for _ in range(t): n = int(ra ...

  4. 【HackerRank】Gem Stones

    Gem Stones John has discovered various rocks. Each rock is composed of various elements, and each el ...

  5. IEEEXtreme 10.0 - Game of Stones

    这是 meelo 原创的 IEEEXtreme极限编程大赛题解 Xtreme 10.0 - Game of Stones 题目来源 第10届IEEE极限编程大赛 https://www.hackerr ...

  6. 日常小测:颜色 && Hackerrank Unique_colors

    题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...

  7. HackerRank "Square Subsequences" !!!

    Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the soluti ...

  8. HackerRank "Minimum Penalty Path"

    It is about how to choose btw. BFS and DFS. My init thought was to DFS - TLE\MLE. And its editorial ...

  9. HackerRank "TBS Problem" ~ NPC

    It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/Charl ...

随机推荐

  1. 关于ionic的跨域问题

    例如你的api原地址请求是 http://10.100.100.100:8080/service/, 1.那么你应该在项目内api请求改成 /service/, 注意红色部分是ionic serve ...

  2. php curl post

    public static function curlPost($url, $data=array()) {        $ch = curl_init();        if (is_array ...

  3. Amazon S3 PHP Class Documentation

    API : http://undesigned.org.za/2007/10/22/amazon-s3-php-class/documentation Example: http://www.phpb ...

  4. openerp学习笔记 视图更新时删除已存在的菜单或其他对象

    删除菜单示例: <delete id="base.menu_module_updates" model="ir.ui.menu"/><dele ...

  5. C# sogou地图API应用总结(二)

    在地图上添加自己想要的功能模块 具体代码如下 var map; window.onload = function () { var myOptions = { mapControl: false, / ...

  6. MySQL 多实例数据库还原脚本-备份集与端口对应

    版本:5.5.14 OS: ConetOS 6.3 1.创建recover.sh [root@yoon  export]# vi  recover.sh #!/bin/bash bakdir=/exp ...

  7. WCF-Configuration

    Host-Configuration <?xml version="1.0"?> <configuration> <configSections> ...

  8. ArcGIS For JavaScript API 默认参数

    “esri.config”的是在1.3版中的的“esriConfig”的替代品.如果您使用的是1.2或更低的版本,您应该参阅默认API v1.2和更低的配置.对于版本1.3或更高版本,您可以使用“es ...

  9. JAVA类与对象(三)----类定义关键字详解

    static 表示静态,它可以修饰属性,方法和代码块. 1.static修饰属性(类变量),那么这个属性就可以用类名.属性名来访问,也就是使这个属性成为本类的类变量,为本类对象所共有.这个属性就是全类 ...

  10. Palindrome Partitioning

    Palindrome Partitioning Given a string s, partition s such that every substring of the partition is ...