A. Round House_数学问题
1 second
256 megabytes
standard input
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.
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.
Print a single integer k (1 ≤ k ≤ n) — the number of the entrance where Vasya will be at the end of his walk.
6 2 -5
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_数学问题的更多相关文章
- POJ 3252 Round Numbers 数学题解
Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, P ...
- Codeforces Round #349
终于又回到熟悉的Round了 数学 A - Pouring Rain 设个未知数,解方程,还好没有hack点 #include <bits/stdc++.h> typedef long l ...
- 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 输入格式 ...
- JavaScipt中的Math.ceil() 、Math.floor() 、Math.round()、Math.pow() 三个函数的理解
以前一直会三个函数的使用产生混淆,现在通过对三个函数的原型定义的理解,其实很容易记住三个函数. 现在做一个总结: 1. Math.ceil()用作向上取整. 2. Math.floor()用作向下取整 ...
- sql server 基础教程[温故而知新三]
子曰:“温故而知新,可以为师矣.”孔子说:“温习旧知识从而得知新的理解与体会,凭借这一点就可以成为老师了.“ 尤其是咱们搞程序的人,不管是不是全栈工程师,都是集十八般武艺于一身.不过有时候有些知识如果 ...
- 随机添加一个Class,Class提前写好
$("").hover(function(){ var ary = ["red","green","blue",]; v ...
- PL/0与Pascal-S编译器程序详细注释
学校编译课的作业之一,要求阅读两个较为简单的编译器的代码并做注释, 个人感觉是一次挺有意义的锻炼, 将自己的心得分享出来与一同在进步的同学们分享. 今后有时间再做进一步的更新和总结,其中可能有不少错误 ...
- sql知识
SQL 基本知识 SQL Server 是Microsoft 公司推出的关系型数据库管理系统.具有使用方便可伸缩性好与相关软件集成程度高等优点,可跨越从运行Microsoft Windows 98 的 ...
- usaco silver
大神们都在刷usaco,我也来水一水 1606: [Usaco2008 Dec]Hay For Sale 购买干草 裸背包 1607: [Usaco2008 Dec]Patting Heads 轻 ...
随机推荐
- 懒汉式单例要加volatile吗
private static volatile Something instance = null; public static Something getInstance() { if (insta ...
- oracle merge into与sqlserver merge into 比较
merge into: 在两个表之间,根据与源表联接的结果,对目标表执行插入.更新或删除操作. Oracle在9i引入了merge into命令,SQL Server 2008也引入merge int ...
- RTT设备与驱动之PIN设备
单片机的PIN有2个基本功能:GPIO和AFIO,其中gpio的常用功能: 1 输入:上拉.下拉.模拟.浮动 2 输出:上拉.下拉.推挽.开漏 3 中断:上升沿.下降沿.双沿.高电平.低电平触发 RT ...
- 关于KEIL下的图形化显示和输出问题
一 keil自带的虚拟示波器:只能在软件仿真下使用:右边的这个可以查看变量. 二 SEGGER的工具软件: 1 RTT:可以进行日志输出调试信息输出,需要配置工程,但不占用串口. 2 JSCOPE:可 ...
- [转]jQuery AJAX pagination plugin with ASP.NET Server Side
本文转自:http://do-web.com/jpaging/usage How does it work? 1. In order to implement the plugin, you need ...
- zuul路由网关
zuul作为网关组件,主要用来管理api请求接口(统一对外暴露,负载均衡),身份认证,流量监控等.它是通过servlet来实现的,核心是一系列过滤器,可以在请求的发起跟相应返回阶段进行一系列的处理. ...
- Jetty数据同步使用
1. Jetty简介 Jetty 是一个开源的servlet容器,它为基于Java的web容器,例如JSP和servlet提供运行环境.Jetty是使用Java语言编写的,它的API以一组JAR包的形 ...
- Emacs学习笔记2
emacs的启动初始化 需要有一个~/.emacs文件, 这个和vim一样 emacs中的查找与替换 递增查找 C-s, 在minibuffer中输入即可, 在一次C-s会跳转到下一个 两次C-g取消 ...
- 【snmp】测试流程
一.SNMP协议概述 SNMP是基于TCP/IP协议族的网络管理标准,是一种在IP网络中管理网络节点(如服务器.工作站.路由器.交换机等)的标准协议.SNMP能够使网络管理员提高网络管理效能,及时发现 ...
- angular2-组件样式
组件样式: :host 选择器 使用:host伪类选择器,用来选择组件宿主元素中的元素(相对于组件模板内部的元素) 这是我们能以宿主元素为目标的唯一方式.除此之外,我们将没办法指定它, 因为宿主不是组 ...