codeforces 659A A. Round House(水题)
题目链接:
1 second
256 megabytes
standard input
standard output
Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided that during his walk he will move around the house b entrances in the direction of increasing numbers (in this order entrance n should be followed by entrance 1). The negative value of b corresponds to moving |b| entrances in the order of decreasing numbers (in this order entrance 1 is followed by entrance n). If b = 0, then Vasya prefers to walk beside his entrance.
Illustration for n = 6, a = 2, b = - 5.
Help Vasya to determine the number of the entrance, near which he will be at the end of his walk.
The single line of the input contains three space-separated integers n, a and b (1 ≤ n ≤ 100, 1 ≤ a ≤ n, - 100 ≤ b ≤ 100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively.
Print a single integer k (1 ≤ k ≤ n) — the number of the entrance where Vasya will be at the end of his walk.
6 2 -5
3
5 1 3
4
3 2 7
3
The first example is illustrated by the picture in the statements.
题意:
n个entrances a为起点,b为步数,问最终在哪,b正是一个方向,负是一个方向;
思路:
水题,不想解释,居然最后挂在了system test 上;
AC代码:
/*
2014300227 659A - 49 GNU C++11 Accepted 15 ms 2172 KB */
#include <bits/stdc++.h>
using namespace std;
int a[];
int main()
{
int n,a,b;
scanf("%d%d%d",&n,&a,&b);
queue<int>qu;
int cnt=;
if(b>)
{
for(int i=a;i<=n;i++)
{
qu.push(i);
}
for(int i=;i<a;i++)
{
qu.push(i);
}
while()
{
qu.push(qu.front());
qu.pop();
cnt++;
if(cnt>=b)
{
cout<<qu.front()<<endl;
break;
}
} }
else if(b<)
{
b=-b;
for(int i=a;i>;i--)
{
qu.push(i);
}
for(int i=n;i>a;i--)
{
qu.push(i);
}
while()
{
qu.push(qu.front());
qu.pop();
cnt++;
if(cnt>=b)
{
cout<<qu.front()<<endl;
break;
}
} }
else
{
cout<<a<<endl;
} return ;
}
codeforces 659A A. Round House(水题)的更多相关文章
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- CodeForces 489B BerSU Ball (水题 双指针)
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- codeforces 702A A. Maximum Increase(水题)
题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Codeforces Round #346 (Div. 2) A. Round House 水题
A. Round House 题目连接: http://www.codeforces.com/contest/659/problem/A Description Vasya lives in a ro ...
- A. Arrays(Codeforces Round #317 水题)
A. Arrays time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...
随机推荐
- 将Cocos2d-x游戏打包成Android应用程序
1. 打开Eclipse(已经装好CDT.ADT和NDK),导入cocos2d-x的Android项目. 2. 导入后java的源码会出现编译错误,打开cocos2d-x引擎的根文件夹\cocos2d ...
- Web前端学习攻略
HTML+CSS: HTML进阶.CSS进阶.div+css布局.HTML+css整站开发. JavaScript基础: Js基础教程.js内置对象常用方法.常见DOM树操作大全.ECMAscript ...
- 双十一前4小时,CentOS 6.5server启动错误排查
11月10日晚上8点多.眼看要到双十一了... 但我要说的这段经历却和双十一毫无关系.哈哈. 这天准备向CentOS6.5server的svn上传一些文件,结果开机启动时,却出现了以下的界面: 这是肿 ...
- Linux trace使用入门
概念 trace 顾名思义追踪信息,可通俗理解为一种高级打印机制,用于debug,实现追踪kernel中函数事件的框架.源代码位于:\kernel\trace\trace.c,有兴趣能够研究 撰写不易 ...
- oracle中视图V$PGA_TARGET_ADVICE的用法
看一下这个视图能给我们带来什么样的信息(视图中每个列都很有帮助):sys@ora10g> SELECT pga_target_for_estimate / 1024 / 1024 " ...
- oracle函数中lead,lag,over,partition by 的使用
lead,lag函数的分析 http://blog.csdn.net/mazongqiang/article/details/7621328 举例如下: SQL> select * from ...
- 摩根大通银行被黑客攻克, ATM机/网银危在旦夕,winxp退市灾难来临了
winxp4月退市到如今还不到半年,就出现故障了 7600多万个消费者银行账户被黑.此外还有700万个小企业账户的信息也被黑客窃取,这个算不算灾难呢?假设等到银行业彻底崩溃,资金彻底丧失,那不仅仅是灾 ...
- PHP操作:将数据库中的数据保存到Word、Excel中。
1.首先要把word.excel表放到文件的根目录下 2.定义了一个word类 <?php class word { function start() { ob_start(); ob_star ...
- 【BZOJ2666】[cqoi2012]组装 贪心
[BZOJ2666][cqoi2012]组装 Description 数轴上有m个生产车间可以生产零件.一共有n种零件,编号为1~n.第i个车间的坐标为xi,生产第pi种零件(1<=pi< ...
- php操作apache服务器上的ftp
在此之前,请先在window7上搭建apache-ftp服务器,请查看文章:Windows 上搭建Apache FtpServer test.php <?php set_time_limit(0 ...