11805 - Bafana Bafana

All about problems in Volume 118. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11805 - Bafana Bafana

Post by brianfry713 » Tue Nov 20, 2012 3:41 am

Input:

Code: Select all

1
23 23 68
AC output:

Code: Select all

Case 1: 22
Check input and AC output for thousands of problems on uDebug!

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 11805-Bafana Bafana

Post by uDebug » Fri Jan 03, 2014 7:32 am

naseef_07cuet wrote: Input:
1
12 14 18
This doesn't seem like it's a valid input. The problem statement clearly says that N (2 <= N <= 23), K (1 <= K <= N). Here K > N.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

fislam
New poster
Posts: 2
Joined: Fri Sep 19, 2014 4:45 am

Re: 11805 - Bafana Bafana

Post by fislam » Fri Sep 19, 2014 5:00 am

why i get wa

Code: Select all

#include<iostream>
#include<cstdio>
int main(){

int n,p,k,remind,i,counter,l;
scanf("%d",&l);
for(int f=1;f<=l;f++){
scanf("%d%d%d",&n,&k,&p);
remind=p%n;
if(remind==0)
    remind=n;
counter=k%n;;
int u=remind;
for(i=1;i<=u;i++){
if(counter==n)
{
    if(i!=u){
    counter=1;
    }
}
else
{
    counter++;
}
}
printf("Case %d: %d\n",f,counter);
}
return 0;
}
Last edited by brianfry713 on Tue Nov 18, 2014 11:21 pm, edited 1 time in total.
Reason: Added code blocks

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11805 - Bafana Bafana

Post by lighted » Fri Sep 19, 2014 11:23 am

Use code tags.

Input

Code: Select all

3
5 3 3
6 4 3
4 2 3
Acc Output

Code: Select all

Case 1: 1
Case 2: 1
Case 3: 1
Don't forget to remove your code after getting accepted. 8)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Xenon Kfr
New poster
Posts: 13
Joined: Tue Nov 18, 2014 1:14 am

Re: 11805 - Bafana Bafana

Post by Xenon Kfr » Tue Nov 18, 2014 1:37 am

i dont know why my code is wrong ?

Code: Select all

Removed after getting accepted
Last edited by Xenon Kfr on Wed Jan 28, 2015 1:12 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11805 - Bafana Bafana

Post by brianfry713 » Tue Nov 18, 2014 11:25 pm

Input:

Code: Select all

1
2 1 3
AC output:

Code: Select all

Case 1: 2
Check input and AC output for thousands of problems on uDebug!

Xenon Kfr
New poster
Posts: 13
Joined: Tue Nov 18, 2014 1:14 am

Re: 11805 - Bafana Bafana

Post by Xenon Kfr » Wed Nov 19, 2014 1:44 am

thanx man

shawon10
New poster
Posts: 4
Joined: Sun Feb 01, 2015 2:43 pm
Location: RUET
Contact:

Re: 11805 - Bafana Bafana

Post by shawon10 » Thu May 21, 2015 3:36 pm

i tried my code by several test cases but still i am getting WA. i don't know why there are some test cases which is not valid like 12 14 18 as k<=n according to question. when k>=n my code is not showing correct outout. should i consider k>n but why?

Code: Select all

#include <stdio.h>
int main()
{
    int n,k,p,t,i,j;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        int f=0;
        scanf("%d %d %d",&n,&k,&p);
        int j=k;
        while(f!=p)
        {
            if(j>n)
            {
                j=1;
            }
              f++;
              j++;



        }

            printf("Case %d: %d\n",i,j);



    }

    return 0;
}

shawon10
New poster
Posts: 4
Joined: Sun Feb 01, 2015 2:43 pm
Location: RUET
Contact:

Re: 11805 - Bafana Bafana

Post by shawon10 » Thu May 21, 2015 4:39 pm

Got Accepted :D . There Was a little bug in my code as i took if condition at first. but now it's working

Code: Select all

#include <stdio.h>
int main()
{
    int n,k,p,t,i,j;
    scanf("%d",&t);
    for(i=1;i<=t;i++)
    {
        int f=0;
        scanf("%d %d %d",&n,&k,&p);
        int j=k;
        while(f!=p)
        {
              f++;
              j++;

            if(j>n)
            {
                j=1;
            }



        }

            printf("Case %d: %d\n",i,j);

    }

    return 0;
}

Post Reply

Return to “Volume 118 (11800-11899)”