Codeforces Round #346 (Div. 2) A. Round House 水题
A. Round House
题目连接:
http://www.codeforces.com/contest/659/problem/A
Description
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.
Input
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.
Output
Print a single integer k (1 ≤ k ≤ n) — the number of the entrance where Vasya will be at the end of his walk.
Sample Input
6 2 -5
Sample Output
3
Hint
题意
给你一个环形轨道,你一开始在a,然后你走b步,问你在哪儿。
题解:
这个小心负数的情况,为了避免这个,我直接将a+=100*n,这样就不会有负数的情况了。
代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,a,b;
cin>>n>>a>>b;a--;
a=a+100*n;
a=a+b;
cout<<a%n+1<<endl;
}
Codeforces Round #346 (Div. 2) A. Round House 水题的更多相关文章
- Codeforces Round #346 (Div. 2) B. Qualifying Contest 水题
B. Qualifying Contest 题目连接: http://www.codeforces.com/contest/659/problem/B Description Very soon Be ...
- Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
- Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...
- Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...
- Codeforces Beta Round #4 (Div. 2 Only) A. Watermelon 水题
A. Watermelon 题目连接: http://www.codeforces.com/contest/4/problem/A Description One hot summer day Pet ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #146 (Div. 1) A. LCM Challenge 水题
A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...
- Codeforces Round #335 (Div. 2) B. Testing Robots 水题
B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...
- Codeforces Round #335 (Div. 2) A. Magic Spheres 水题
A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...
随机推荐
- 发行NEO的NEP-5合约代币
NEO常见的资产有三种 TOKEN (全局资产) Share (全局资产,股份 ) NEP-5 (合约代币,相当于ETH的ERC20) NEP-5 合约代码 https://github.com/AN ...
- 72.Edit Distance---dp
题目链接:https://leetcode.com/problems/edit-distance/description/ 题目大意:找出两个字符串之间的编辑距离(每次变化都只消耗一步). 法一(借鉴 ...
- 「caffe编译bug」 undefined reference to `boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::__cxx11
CXX/LD -o .build_release/tools/test_net.binCXX/LD -o .build_release/tools/convert_annoset.binCXX/LD ...
- caffe Python API 之Inference
#以SSD的检测测试为例 def detetion(image_dir,weight,deploy,resolution=300): caffe.set_mode_gpu() net = caffe. ...
- php cache类代码(php数据缓存类)
如果访问量大的话会给数据库造成很大的负担,所以对于变化不经常的内容要做好php 数据cache(缓存)是十分必要的,我做了一个简单的php“文件缓存”的类,希望对大家有所帮助. 思路是这样的: 对于一 ...
- java版云笔记(四)
页面的笔记本加载完成了,接下来就是点击笔记本显示将笔记显示,同时把笔记在右边的编辑器中,同时把编辑后的笔记更新. 注:这个项目的sql文件,需求文档,需要的html文件,jar包都可以去下载,下载地址 ...
- Nginx1.8.1 编译扩展https
nginx无缝编译扩展https 本贴只限用于通过编译安装的nginx,如果用的是yum源安装请卸载后参见 http://www.cnblogs.com/rslai/p/7851220.html 安装 ...
- Effective C++笔记(六):继承与面向对象设计
参考:http://www.cnblogs.com/ronny/p/3756494.html 条款32:确定你的public继承塑模出is-a关系 “public继承”意味着is-a.适用于base ...
- scrollview 滚动布局
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layou ...
- 语言模型srilm基本用法
目录: 一基本训练 二语言模型打分 三语言模型剪枝 四语言模型合并 五语言模型使用词典限制 一.基本训练 #功能 读取分词后的text文件或者count文件,然后用来输出最后汇总的count文件或者语 ...