【CodeForces】[659A]Round House

Problem Description

Loading...

Problem Analysis

A fairly easy problem
Use modulo to achieve the circular effect

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
int main() {
	int n,a,b;
	while(scanf("%d %d %d",&n,&a,&b)!=EOF) {
		if(b==0)
			printf("%d\n",a);
		else {
			b%=n;
			if(b>0) {
				if(a+b==n)
					printf("%d\n",n);
				else
					printf("%d\n",(a+b)%n);
			} else {
				if(a+b>0)
					printf("%d\n",a+b);
				else
					printf("%d\n",n+a+b);
			}
		}
	}
	return 0;
}

Problem link: 【CodeForces】[659A]Round House

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...