[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;
}
[hackerrank]Manasa and Stones的更多相关文章
- 【HackerRank】Manasa and Stones
Change language : Manasa 和 她的朋友出去徒步旅行.她发现一条小河里边顺序排列着带有数值的石头.她开始沿河而走,发现相邻两个石头上的数值增加 a 或者 b. 这条小河的尽头有一 ...
- HackerRank "Manasa and Prime game"
Intuitive one to learn about Grundy basic :) Now every pile becomes a game, so we need to use Spragu ...
- Manasa and Stones
from __future__ import print_function def main(): t = int(raw_input()) for _ in range(t): n = int(ra ...
- 【HackerRank】Gem Stones
Gem Stones John has discovered various rocks. Each rock is composed of various elements, and each el ...
- IEEEXtreme 10.0 - Game of Stones
这是 meelo 原创的 IEEEXtreme极限编程大赛题解 Xtreme 10.0 - Game of Stones 题目来源 第10届IEEE极限编程大赛 https://www.hackerr ...
- 日常小测:颜色 && Hackerrank Unique_colors
题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...
- HackerRank "Square Subsequences" !!!
Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the soluti ...
- 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 ...
- HackerRank "TBS Problem" ~ NPC
It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/Charl ...
随机推荐
- WinForm 实现验证码
private void CheckIdentifyingCode() { Random r = new Random(); string str = ""; for (int i ...
- 关于iOS6应用中第三方类库不支持armv7s的问题解决
今天编译ios6+cocos2d v2 .1 beta2制作的游戏,出现下面的错误: ld: file is universal (3 slices) but does not contain a(n ...
- 我的第一个MVC4程序
InputExtensions 方法解释 http://blog.csdn.net/cnceohjm/article/details/8936669 https://msdn.microsoft.co ...
- Jquery LigerUI框架学习(二)之Tree于Tab标签实现iframe功能
LigerUI框架Tree于Tab标签动态使用,当点击Tree后动态创建Tab标签,和通常用的iframe框架功能类似 Tree中的关键代码 //Tree初始化 $("#tree1" ...
- 微软更换考试中心后报名攻略以及MCT半价
微软从Prometric更换为Pearson的考试中心,比起以前的预约流程更加便捷. Pearson VUE为微软公司提供MCP考试服务 Pearson VUE为微软公司提供MCP考试服务 http: ...
- sysfs分析
Linux设备模型——设备驱动模型和sysfs文件系统解读 内核版本:2.6.30 1. What is sysfs? 个人理解:sysfs向用户空间展示了驱动设备的层次结构.我们都知道设备和对应 ...
- iOS 开发之粒子效果
本文由糖炒小虾.Benna翻译 ,校对:sai.u0u0.iven.子龙山人 iOS 5中的UIKit粒子系统教程 Ray的话:这是第15篇.也是最后一篇<iOS 5 盛宴>中的iOS 5 ...
- nodejs redis
0. install redis library for node npm install redis 1.node command example > var _redis = require ...
- sql行转列和列转行(转)
行列互转,是一个经常遇到的需求.实现的方法,有case when方式和2005之后的内置pivot和unpivot方法来实现. 在读了技术内幕那一节后,虽说这些解决方案早就用过了,却没有系统性的认识和 ...
- Oracle 多行记录合并/连接/聚合字符串的几种方法
怎么合并多行记录的字符串,一直是oracle新手喜欢问的SQL问题之一,关于这个问题的帖子我看过不下30个了,现在就对这个问题,进行一个总结.-什么是合并多行字符串(连接字符串)呢,例如: SQL&g ...