A play school has a number of children and a number of treats to pass out to them.
Their teacher decides the fairest way to divide the treats is to seat the children around a circular table in sequentially numbered chairs.
A chair number will be drawn from a hat. Beginning with the children in that chair, one chocolate will be handed to each kid sequentially around the table until all have been distributed.
The teacher is playing a little joke, though. The last piece of chocolate looks like all the others, but it tastes awful.
Determine the chair number occupied by the child who will receive that chocolate.
Input:
The first line contains an integer, 't', the number of test cases.
Then t lines follows
The next lines each contain space-separated integers:
n: the number of children
m: the number of chocolates
s: the chair number to start passing out treats at
Output:
Print the chair number occupied by the child who will receive that chocolate.
Explanation:
Assume n=4 m =6 and s =2 then
There are 4 children, 6 pieces of chocolates and distribution starts at chair 2 .
The children's arrange themselves in seats numbered 1 to 4 .
Children receive chocolates at positions 2,3,4,1,2,3 . The Children's to be warned sits in chair number 3.
#include <stdio.h> void loop() { printf("ans=(long int *)malloc(t*sizeof(long int)); long int t,n,m,s,*ans"); long int n,m,s; scanf("%ld %ld %ld",&n,&m,&s); } int main() { int t; scanf("%d",&t); while(t--) {int a,b,c,d; scanf("%d%d%d",&a,&b,&c); d=(b%a)+c-1; if(d<=a) d=d; else d=d-a; printf("%d\n",d); } return 0; }
INPUT_1:
4
12 17 8
10 23 4
18 34 3
15 21 5
OUTPUT:
12
6
18
10
INPUT_2:
2
7 19 2
3 7 3
OUTPUT:
6
ILLUSTRATION
Morae Q!
- Find the number of strings made by using each alphabet as starting character.
- Find the Pythagorean triplet.
- Find out what is the minimum possible energy he needs to spend.
- Sort the array in non-decreasing order and print out the original indices of sorted array.
- Compute the number of landmasses on the planet after all the meteorites have fallen.
- Give the appropriate server status as output.
- Regular expressions (Regex) using search module in python.
- Find the minimum distance between any pair of equal elements in the array.
- Find the total number of matching pairs of socks that are available.
- Find the total number of teams which can work together and cannot work together.
- Given the heights of all the boys and girls tell whether it is possible for all boys to get a girl.
- Find the sequence of cities to visit according to coordinates and conditions.
- Find the number of unique patches of rectangular land to grow samba(rice) in.
- Regular expression Regex matching strings.
- Generate a greeting quote for admin.
- Find all the cavities on the map and replace their depths with the character X.
- Check whether the given graph is Bipartite or not.
- Find the status of the passengers and safari cars at zoo after k units of time.
- Determine the chair number occupied by the child who will receive that chocolate.
- Check if Rubik’s cube of any dimensions can be assembled.