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 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 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
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

int main()
{
int n,a,b;
scanf("%d%d%d",&n,&a,&b); int ans; int c=b%n; ans=(n+a+c)%n; printf("%d\n",ans==?n:ans);
return ;
}

A. Round House_数学问题的更多相关文章

  1. POJ 3252 Round Numbers 数学题解

    Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, P ...

  2. Codeforces Round #349

    终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...

  3. CH BR13数学(啥?-a^b≡a^b mod phi(p)+phi(p)(mod p)(b>=phi(p))公式)

    啥? Beta Round #13 (数学专场) 背景 有人写了一个RSA加密给我玩. 描述 我赌5毛前面两题的内容也就开头几句话平时会用到. 还是做点具体的东西吧. 求c^d Mod N 输入格式 ...

  4. JavaScipt中的Math.ceil() 、Math.floor() 、Math.round()、Math.pow() 三个函数的理解

    以前一直会三个函数的使用产生混淆,现在通过对三个函数的原型定义的理解,其实很容易记住三个函数. 现在做一个总结: 1. Math.ceil()用作向上取整. 2. Math.floor()用作向下取整 ...

  5. sql server 基础教程[温故而知新三]

    子曰:“温故而知新,可以为师矣.”孔子说:“温习旧知识从而得知新的理解与体会,凭借这一点就可以成为老师了.“ 尤其是咱们搞程序的人,不管是不是全栈工程师,都是集十八般武艺于一身.不过有时候有些知识如果 ...

  6. 随机添加一个Class,Class提前写好

    $("").hover(function(){ var ary = ["red","green","blue",]; v ...

  7. PL/0与Pascal-S编译器程序详细注释

    学校编译课的作业之一,要求阅读两个较为简单的编译器的代码并做注释, 个人感觉是一次挺有意义的锻炼, 将自己的心得分享出来与一同在进步的同学们分享. 今后有时间再做进一步的更新和总结,其中可能有不少错误 ...

  8. sql知识

    SQL 基本知识 SQL Server 是Microsoft 公司推出的关系型数据库管理系统.具有使用方便可伸缩性好与相关软件集成程度高等优点,可跨越从运行Microsoft Windows 98 的 ...

  9. usaco silver

    大神们都在刷usaco,我也来水一水 1606: [Usaco2008 Dec]Hay For Sale 购买干草   裸背包 1607: [Usaco2008 Dec]Patting Heads 轻 ...

随机推荐

  1. 通过JS,按照原比例控制图片尺寸

    <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Con ...

  2. mongodb在windows下安装

    下载地址:https://www.mongodb.com/download-center/community 我下载的是zip版本 新建目录:data |_db |_log cmd到所下载的mongo ...

  3. 3 不用IDE开发groovy

    1       不用IDE开发groovy 1.1  不用IDE开发的方法 可以在IDE中运行Groovy类或者脚本,但是Groovy也提供了其他运行途径.你能运行Groovy代码基于以下: ·    ...

  4. Python的Profilers性能分析器

    关于Python Profilers性能分析器 关于性能分析,python有专门的文档,可查看:http://docs.python.org/library/profile.html?highligh ...

  5. Django易混淆问题

    1.Django本身提供了runserver 为什么不能用来 部署 runserver 方法是调试 Django 时经常用到的运行方式,它使用 Django 自带的  WSGI Server 运行,主 ...

  6. [转]如何在.NET MVC中使用jQuery并返回JSON数据

    本文转自:http://blog.sina.com.cn/s/blog_48e42dc90100xp1p.html 二.开始实践 - jQuery端 假设我们要从服务器端获取一个文章列表,并把文章条目 ...

  7. HTML5中video标签与canvas绘图的使用

    video标签的使用 video标签定义视频, 它是html5中的新标签, 它的属性如下(参考自文档): domo01 <!DOCTYPE html> <html lang=&quo ...

  8. apache服务器启动出错

    启动本地xampp的服务器时,报错如下所示: 错误提示很明确: 就是指我们希望使用的端口被占用,由于xampp默认使用的端口是80(http协议).443(https协议),也就是说这两个端口被其他的 ...

  9. HIbernate基于外键的查询

    此文以个人开发记录为目的,笔拙勿喷 项目是背景是公司的E签宝平台VIP频道项目进行关联账户增加后,需要做删除时的,联合查询 当前主要表结构账户表Account. CREATE TABLE `accou ...

  10. HDU 4336——Card Collector——————【概率dp】

    Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...