[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 ...
随机推荐
- NaN 和 Infinity
using Fasterflect; using System; using System.Collections.Generic; using System.Linq; using System.R ...
- nginx反向代理的配置优化
作者:守住每一天 blog:liuyu.blog.51cto.combbs:bbs.linuxtone.orgmsn:liuyubj520#hotmail.comemail:liuyu105#gmai ...
- [Solved] install Gentoo in VBox: network interface eth0 does not exist
ERROR:interface eth0 does not exist; ensure that you have loaded the correct kernel moudle for your ...
- -sh: ./helloworld: not found
最近在玩FriendlyARM mini2440的板子,编译了一个helloworld,通过ftp上传到开发版的文件系统中,chmod 777 helloworld,运行./helloworld,出现 ...
- python post中文引发的不传递,及乱码问题
使用jquery ajax向后台传值 $.ajax({ type:"POST", url:"" data:{ content:content }, succes ...
- IE6和IE7的line-height和现代浏览器不一致的问题
1.我们发现在网页中设置line-height后,现代浏览器显示正常,可是在IE6 IE7下却不能正确解析,这时需要再额外的为旧版浏览器声明: p{ line-height: 30px; *line- ...
- C#实现发送邮件——核心部分代码
在KS系统中有个发送邮件的功能需要做上网查阅资料以后,通过自己的部分修改实现了发送邮件的功能话不多说先来个界面: 邮件发送分一下步骤: 1.smtp服务信息设置 2.验证发件人信息 3.添加附件 4. ...
- RMAN备份失败之:mount: block device /dev/emcpowerc1 is write-protected, mounting read-only
今天再做巡检的时候发现有一台服务器的RMAN备份不正常,有一段时间没能正常备份了.检查了一下脚本,正常,定时任务列表也正常,再检查一下/var/log/cron的内容,也没有问题.尝试在该挂载点上创建 ...
- EntityFramework常用查询
Sql语句.存储过程: 1.无参数查询var model = db.Database.SqlQuery<UserInfo>("select* from UserInfoes &q ...
- python调用C语言
标签(空格分隔): python test.c代码如下 #include<stdio.h> void display(char* msg) { printf("%s\n" ...