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. 在Linux中三种让crontab每秒执行任务的方法

    第一种方法: 1.创建脚本文件 cat phplog.sh 2.编辑脚本内容 #!/bin/bash while : ;do /home/scripts.sh 2>/dev/null & ...

  2. C#中gridView常用属性和技巧介绍

    .隐藏最上面的GroupPanel gridView1.OptionsView.ShowGroupPanel=false; .得到当前选定记录某字段的值 sValue=Table.Rows[gridV ...

  3. js关闭页面(兼容浏览器)

    function closewindow() { window.opener = null; window.open("", "_self"); window. ...

  4. JMS消息头

    一个消息对象分为三部分:消息头(Headers),属性(Properties)和消息体(Payload).对于StreamMessage和MapMessage,消息本身就有特定的结构,而对于TextM ...

  5. XenServer安装虚拟机---先扩容存放ISO镜像文件

    我们都知道xenserver安装后,不管你的盘有多大,只有4G的空间. 故操作是:新建LV卷,可自定义大小 1.vgdisplay #先查看剩余空间 [root@XenServer /]# vgdis ...

  6. RethinkDB

    RethinkDB最早是作为一个对SSD进行专门优化的MySQL存储引擎出现的,其特点在于对SSD的充分利用.而目前RethinkDB已经脱离MySQL成为一个独立的存储. RethinkDB目前支持 ...

  7. Android开发笔记一(hello world)

    UI: <Button android:layout_width="wrap_content" android:layout_height="wrap_conten ...

  8. EditorWindow 和MenuItem

    using UnityEngine; using System.Collections; using UnityEditor; public class ClipEventEditor : Edito ...

  9. 爬虫组NABC

    Need(需求): 我们小组的研究课题是编写一个更实用的爬虫软件,编写时会应用到学长的部分代码并在其基础上完善创新. 鉴于学长代码已经实现了基本功能,即从网站上面爬取相关的Word文档等与计算机有关的 ...

  10. 被git extensions给坑了,Not owner 解决办法

    我只遇到这一种情况,不能访问git文件主库, 清空以前的历史文件,包括默认配置文件,重新安装一遍git extension,然后设置账号和密码, 在打开bash设置私钥和公钥 把公钥添加到你的git的 ...