A. Round House

题目链接http://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.

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

题意:

给你一个环,你一开始在a位置,然后你走b步,求走完后地址。

题解:

先将最环节全部去掉,剩下绝对值在a以内的数。这样就可以通过环的性质求出数据。

代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn = 1123456789;
int s[1000];
int main()
{
int key = 0;
int n,a,b;
cin>>n>>a>>b;
if (b >= 0){
if ((a+b)%n == 0)
cout<<n<<endl;
else cout<<((a+b)%n)<<endl;;
}else {
int sb = b;
while (sb < 0){
sb+=n;
}
if ((a+sb)%n == 0)
cout<<n<<endl;
else cout<<((a+sb)%n)<<endl;; } return 0;
}

Codeforces Round #346 (Div. 2) A Round-House的更多相关文章

  1. 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 ...

  2. Codeforces Round #346 (Div. 2)---E. New Reform--- 并查集(或连通图)

    Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory lim ...

  3. Codeforces Round #346 (Div. 2) A题 [一道让我生气的思维题·]

    A. Round House Vasya lives in a round building, whose entrances are numbered sequentially by integer ...

  4. Codeforces Round #346 (Div. 2) D Bicycle Race

    D. Bicycle Race 题目链接http://codeforces.com/contest/659/problem/D Description Maria participates in a ...

  5. Codeforces Round #346 (Div. 2) C Tanya and Toys

    C. Tanya and Toys 题目链接http://codeforces.com/contest/659/problem/C Description In Berland recently a ...

  6. Codeforces Round #346 (Div. 2) B Qualifying Contest

    B. Qualifying Contest 题目链接http://codeforces.com/contest/659/problem/B Description Very soon Berland ...

  7. Codeforces Round #346 (Div. 2) G. Fence Divercity dp

    G. Fence Divercity 题目连接: http://www.codeforces.com/contest/659/problem/G Description Long ago, Vasil ...

  8. Codeforces Round #346 (Div. 2) F. Polycarp and Hay 并查集 bfs

    F. Polycarp and Hay 题目连接: http://www.codeforces.com/contest/659/problem/F Description The farmer Pol ...

  9. Codeforces Round #346 (Div. 2) E. New Reform dfs

    E. New Reform 题目连接: http://www.codeforces.com/contest/659/problem/E Description Berland has n cities ...

随机推荐

  1. linux history 命令详解

    linux history 命令详解 显示命令执行时间 linux shell 具有history 功能,即会记录已经执行过的命令,但是默认是不显示命令的执行时间,命令的执行时间,history 已经 ...

  2. hdu2534-Score

    http://acm.hdu.edu.cn/showproblem.php?pid=2534 由题知, 每一个数据都可以由ax +by组成: ax1 + by1 - c x2 a - d y2 == ...

  3. cocos2d(x) HTML label ;CCHTML CCHTMLLabel

    这几天由于特殊需要,写了一个HTMLLabel.可以直接支持HTML的几种格式,<font> <a href> color size 等等. 参考object C的一个ios开 ...

  4. Android应用--简、美音乐播放器获取专辑图片(自定义列表适配器)

    Android应用--简.美音乐播放器获取专辑图片(自定义列表适配器) 2013年7月3日简.美音乐播放器开发 第二阶段已增加功能: 1.歌词滚动显示 2.来电监听 3.音量控制 4.左右滑动切换歌词 ...

  5. android.view.WindowManager$BadTokenException: Unable to add window — token null is not for an applic

    之前遇到过这样的问题, 04-12 10:40:33.302: E/AndroidRuntime(17213): Caused by: android.view.WindowManager$BadTo ...

  6. C语言与汇编“硬在哪里”——什么是面向硬件?

    Jack:为什么说C/C++语言是偏向硬件的语言呢? 我:这是把C与java等无指针/引用类编程语言相比较而得出的结论.因为java在j2ee的框架下,写的代码仅仅是逻辑,本质上和写shell脚本没啥 ...

  7. Servlet的ClassLoader

    摘自深入java web技术内幕修订版

  8. List中函数用法 First,FirstOrDefault,Single,SingleOrDefault的区别

    操作符 如果源序列是空的 源序列只包含一个元素 源序列包含多个元素 First 抛异常 返回该元素 返回第一个元素 FirstOrDefault 返回default(TSource) 返回该元素 返回 ...

  9. jQuery插件slides实现无缝轮播图特效

    初始化插件: slides是一款基于jQuery无缝轮播图插件,支持图内元素动画,可以自定义动画类型 1 2 3 4 5 6 7 8 9 10 $(".slideInner").s ...

  10. oracle ebs 分类账与法人主体对应关系

    --ebs 分类账与法人主体对应关系 SELECT A.SET_OF_BOOKS_ID LEDGER_ID, GL.NAME LEDGER_NAME, GL.CURRENCY_CODE, FFV.FL ...