Save The Prisoner!

 Question :-

https://www.hackerrank.com/challenges/save-the-prisoner/problem

Solution in C language :-

#include<stdio.h>
int main(){
    long long int t,n,m,s,sum;
    scanf("%lld",&t);
    for(int i=0;i<t;i++){
        scanf("%lld%lld%lld",&n,&m,&s);
        long long int temp=m%n;
        if((temp+s-1)%n==0){
            printf("%lld\n",n);
        }
        else{
            printf("%lld\n",((temp+s-1)%n));
        }  
    }

    return 0;
}

Comments

Popular posts from this blog

Sherlock and Squares

Cut The Sticks

Home