SONAM GUPTA BEWFA HAI– EDITORIAL
Author: bigo_admin
Tester and Editorialist: subhasis10
Problem Links:- Contest
and Practice
DIFFICULTY: EASY
PREREQUISITES: Modulus Operator
PROBLEM:
Given two numbers N (denoting starting index) and K(denoting number of elements crossed), we have to find at which index we currently are.
EXPLANATION:
Here we are given a starting index N from which we start and K the number of people the bottle has crossed while rotating. So the total number of indices traversed is N+K. Now since there are 5 people in the round table arrangement we make (N+K)%5 which represents the index upto which the bottle has traversed. But in our question we require the number of indices we have crossed, so the answer is (N+K)%5+1.
CODE:
#include long long int k,ans; main() { int t,n; scanf("%d",&t); while(t-- ) { scanf("%d%lld",&n,&k); ans = (n+k)%5+1; printf("%d\n",ans); } }