CodeForces 659A Round House
来源:互联网 发布:node.js 编译 编辑:程序博客网 时间:2024/06/07 07:34
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
3
5 1 3
4
3 2 7
3
题意:给你一个环,给出起点和步数(正负方向不同),问能走到哪。
思路:模拟一遍就可以了。
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){int num[210],n,a,b,m,i,j;while(scanf("%d%d%d",&n,&a,&b)!=EOF){for(i=1;i<=n;i++)num[i]=i;for(i=n+1;i<=2*n;i++)//这是一个比较机智的地方。 num[i]=i-n;if(b<0){b=-b;b=b%n;b=n-b;} else { b=b%n;}printf("%d\n",num[a+b]);}return 0;}
- 【CodeForces】[659A]Round House
- 【Codeforces】659A - Round House
- CodeForces-659A-Round House
- CodeForces 659A Round House
- CodeForces 659A Round House
- codeforces 659A Round House
- Codeforces 659A Round House (模拟)
- Codeforces 659A Round House【水题,细节】
- Codeforces 659A Round House 【小数学】
- CodeForces 659A Round House(水题)
- CodeForces 659A Round House(技巧)
- Codeforces Round #408 A. Buying A House
- CodeForces - 659A Round House (形成环)水
- Codeforces 659A:Round House(模拟,转化)
- CodeForces 659 A. Round House(简单数学推理)
- Codeforces Round #346 (Div. 2) -A. Round House(模拟)
- Codeforces Round #346 (Div. 2)--A. Round House
- Codeforces Round #346 (Div. 2) A.Round House
- JAVA 继承、方法重写、多态学习笔记
- 新闻发布网页-1
- 天梯匹配系统 - 简单实现
- S6720 核心交换配置实战
- android开发那些事儿(五)-通用流行框架大全
- CodeForces 659A Round House
- ToolBar的使用
- 教你如何用Circleimageview十秒钟写出万能视频的Android圆形控件适配器
- 周赛Problem 1025: Hkhv love spent money(RMQ)
- Reasons for feature scaling
- SparkStreaming0nHDFS实战
- 如何用Visio2013画状态转换图
- 浏览器主页被hao劫持问题解决
- python学习的经典书籍