A. Round House
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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 bcorresponds 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 na 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.

Examples
input
6 2 -5
output
3
input
5 1 3
output
4
input
3 2 7
output
3

题意:1~n个数围成一个圆形,a为起点,b为将要走的步数,b>0则顺时针走b步,b<0逆时针走b步问最后终点是哪个点
#include<stdio.h>
#include<string.h>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define II __int64
#define DD double
#define MAX 10010
#define mod 10003
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
int n,m,a,b,i,j;
while(scanf("%d%d%d",&n,&a,&b)!=EOF)
{
// printf("%d\n",-5%3);
int sum=0;
if(b==0) sum=a;
else if(b<0)
{
b=b%n;
if(a+b<=0)
sum=n+a+b;
else
sum=a+b;
}
else if(b>0)
{
b=b%n;
if(a+b<=n)
sum=a+b;
else
sum=a+b-n;
}
printf("%d\n",sum);
}
return 0;
}

  

codeforces 659A Round House的更多相关文章

  1. Codeforces 659A Round House【水题,细节】

    题目链接: http://codeforces.com/contest/659/problem/A 题意: 一个圈,按逆时针编号,给定起点,方向和步数,问终点在几号? 分析: 很简单的模拟...注意答 ...

  2. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  3. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  4. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  5. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  6. CodeForces Global Round 1

    CodeForces Global Round 1 CF新的比赛呢(虽然没啥区别)!这种报名的人多的比赛涨分是真的快.... 所以就写下题解吧. A. Parity 太简单了,随便模拟一下就完了. B ...

  7. Codeforces Global Round 1 - D. Jongmah(动态规划)

    Problem   Codeforces Global Round 1 - D. Jongmah Time Limit: 3000 mSec Problem Description Input Out ...

  8. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  9. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

随机推荐

  1. 51nod1295 XOR key

    第一次写可持久化trie指针版我... //Null 的正确姿势终于学会啦qaq... #include<cstdio> #include<cstring> #include& ...

  2. 基于Flume的美团日志收集系统(一)架构和设计

    美团的日志收集系统负责美团的所有业务日志的收集,并分别给Hadoop平台提供离线数据和Storm平台提供实时数据流.美团的日志收集系统基于Flume设计和搭建而成. <基于Flume的美团日志收 ...

  3. JS改变input的value值不触发onchange事件解决方案 (转)

    方法(一)(转载的网络资料) 需要了解的知识     首先,我们需要了解onchange和onpropertychange的不同: IE下,当一个HTML元素的属性改变的时候,都能通过 onprope ...

  4. android 带边框的圆角按钮

    新建buttonstyle.xml 代码如下 <?xml version="1.0" encoding="UTF-8"?> <layer-li ...

  5. 嵌入式 使用udev高效、动态地管理Linux 设备文件

    本文以通俗的方法阐述 udev 及相关术语的概念.udev 的配置文件和规则文件,然后以 Red Hat Enterprise Server 为平台演示一些管理设备文件和查询设备信息的实例.本文会使那 ...

  6. c#枚举自定义,用于数据绑定。 z

    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Enum)] public ...

  7. jquery小技巧汇总 持续更新中

    1.jquery高亮当前选中菜单 $("document").ready(function(){ $(".menu li").click(function(){ ...

  8. 书签(Bookmarks)

    工作台允许使用者在文件中创建书签,通过这些书签,使用者可以从书签视图里快速打开这些文件,并跳转到相应的行. (1)在编辑器左边灰色的区域里单击鼠标右键,在弹出的菜单里选择“Add Bookmark.. ...

  9. NewtonPrincipia_物体的运动_求向心力

    NewtonPrincipia_物体的运动_求向心力 让我们看一下十七世纪的被苹果砸中的艾萨克,是怎样推导出向心力公式的 在现在的观点看来,其中涉及到的很多没有符号表示的微分量.下面的内容只是叙述了推 ...

  10. linux下安装filezilla客户端遇到的问题

    访问filezilla ./filezilla 出现error while loading shared libraries : libpng12.so.o 缺少libpng12.so.o这个文件 解 ...