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. 有趣的win8进度条

    有趣的win8进度条 刚才在安装visual studio 12,发现它的安装界面都是win8风格的,而且安装的时候有个进度条,看着挺不错,就用 jquery 实现了一下,的确挺有趣: 点击停止效果 ...

  2. c# datagridview 设置某行不可见解决办法

    [前提]datagridview与数据库绑定,需要单独设置某行或者某个单元格不可见. [问题分析]直接用this.dataGridCiew1.Rows[0].Visible = false;不可行,会 ...

  3. SSD Buffer Pool Extension

    SSD Buffer Pool Extension 简介 SQL Server 2014中另一个非常好的功能是,可以将SSD虚拟成内存的一部分,来供SQL Server数据页缓冲区使用.通过使用SSD ...

  4. java applet初探之计算器

    这里是用java写的一个计算器,用appllet的方式在浏览器中运行,如果电脑上装有java运行环境jre就能一试.将html代码保存为*.html(名称能够自定),applettest编译为clas ...

  5. Qt在表格中加入控件

    任务:使用QTableWidget动态生成表格,在每行的某两列中加入QComboBox下拉框控件和QPushButton按钮控件 有添加,删除,编辑功能,每行的按钮可以浏览文件夹并选择文件 1.新建一 ...

  6. android引导页的实现 及跳转到主页面

    第一个activity package com.qualitypicture.activity; import java.util.ArrayList; import java.util.List; ...

  7. bdev文件系统

    文件系统,是对磁盘数据进行组织和管理的一种机制. 可通过装载,以目录和文件的形式向用户层呈现.但,文件和目录其实只是文件系统的前端而已,只是文件系统的用户视图,其本质还在于这样的一个数据结构:inod ...

  8. 浅析ARP协议及ARP攻击

    一. ARP数据包结构 (1)硬件类型:指明发送方想知道的硬件接口类型,以太网的值为1:(2)协议类型:指明发送方提供的高层协议类型:它的值为 0x0800 即表示 IP地址.(3)硬件地址长度和协议 ...

  9. mybatis-generator 代码自动生成工具(maven方式)

    由于MyBatis属于一种半自动的ORM框架,所以主要的工作将是书写Mapping映射文件,但是由于手写映射文件很容易出错,mybatis-gennerator插件帮我们自动生成mybatis所需要的 ...

  10. xtrabackup在线备份及还原

    xtrabackup下载https://www.percona.com/downloads/XtraBackup/LATEST/xtrabackup文档https://www.percona.com/ ...