#include<stdio.h>
int main()
{
int i, j, n, k, p, count, t;
while(scanf("%d", &t) != EOF)
{
for(i=1;i<=t;i++)
{
scanf("%d %d %d", &n, &k, &p);
count = 0;
for(j=k; ;j++)
{
if(count == p)
break;
if(j == n)
{
count++;
j = 0;
}
else
count++;
}
printf("Case %d: %d\n", i, j);
}
}
return 0;
}
int main()
{
int i, j, n, k, p, count, t;
while(scanf("%d", &t) != EOF)
{
for(i=1;i<=t;i++)
{
scanf("%d %d %d", &n, &k, &p);
count = 0;
for(j=k; ;j++)
{
if(count == p)
break;
if(j == n)
{
count++;
j = 0;
}
else
count++;
}
printf("Case %d: %d\n", i, j);
}
}
return 0;
}
Comments
Post a Comment