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 轻 ...
随机推荐
- spring session使用日志
请求进入和退出时,filter触发session的提取和保存 getAttribute时会查询数据库 setAttribute会保存到数据库 daemond线程定时自动删除过期的session s ...
- 在Mac上安装mysql
进入这个网站: https://dev.mysql.com/downloads/mysql/ 然后点击安装就行了. 注意在这里启动mysql 然后mac上所有的mysql命令都得用绝对路径才能生效
- 数据库迁移expdp impdp 与 OGg 搭建
1.long 字段的无法使用OGG 同步 2.clob字段的导入导出Bug , 生产使用network-link 导入导出太慢了,本地导入导出速度会快3到4倍 .但是测试环境的情况却相反 测试环境和生 ...
- python 下载图片
import requests from PIL import Image from io import BytesIO url = 'http://image2.buslive.cn/shp/upl ...
- How to Fold a Julia Fractal
How to Fold a Julia FractalA tale of numbers that like to turn http://acko.net/blog/how-to-fold-a-ju ...
- CAD安装失败怎样卸载CAD 2018?错误提示某些产品无法安装
AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...
- EDP项目结构规范心得
本文结合最近心得,希望对项目结构方面知识进行归纳,包括两部分 一.目录结构的说明 二.目录结构标准规范(以百度efe团队为例) 下面切入正题: 一.项目目录结构说明: 项目结构具体说明: 1.src目 ...
- Cgroup blkio简介和测试(使用fio测试)
Cgroup blkio简介和测试(使用fio测试) 因需要对docker镜像内的进程对磁盘读写的速度进行限制,研究了下Cgroup blkio,并使用fio对其iops/bps限速进行测试. Cgr ...
- linux 下库的深入调研
linux操作系统中,linux库文件路径还是比较常用的,于是我研究了一下linux库文件路径,在这里拿出来和大家分享一下,希望对大家有用. 库文件在连接(静态库和共享库)和运行(仅限于使用共享库的程 ...
- 新浪微博OAuth2授权错误 error:redirect_uri_mismatch
最近想在app进行新浪微博认证,结果发现总是报error:redirect_uri_mismatch错误. 网上搜了解决方法. 进入 http://open.weibo.com/apps/app_ke ...