11830 - Contract Revision

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

sms.islam
New poster
Posts: 19
Joined: Sat Oct 10, 2009 10:28 am

11830 - Contract Revision

Post by sms.islam » Sat Sep 25, 2010 6:17 pm

i got wa several times. my input output is given below....................please give me some critical input and output.

5 5000000
3 123456
9 23454324543423
9 99999999991999999
7 777
1 1000002
1 10000203
5 5000000000000000000000000000000000000041
5 1051
........................................................
0
12456
23454324543423
1
2
203
41
101
[c]
please....................

pdwd
New poster
Posts: 19
Joined: Sat May 15, 2010 4:35 pm

Re: Contract revision_11830

Post by pdwd » Sun Sep 26, 2010 2:46 am

You don't have answer for 7 777 in your output.

sms.islam
New poster
Posts: 19
Joined: Sat Oct 10, 2009 10:28 am

Re: Contract revision_11830

Post by sms.islam » Mon Sep 27, 2010 2:31 pm

[]
point taken.i missed it.It will be

7 777------------>1

now please help me through it
[]

pdwd
New poster
Posts: 19
Joined: Sat May 15, 2010 4:35 pm

Re: Contract revision_11830

Post by pdwd » Tue Sep 28, 2010 3:21 am

7 777 should be 0

Shafaet_du
Experienced poster
Posts: 147
Joined: Mon Jun 07, 2010 11:43 am
Location: University Of Dhaka,Bangladesh
Contact:

Re: Contract revision_11830

Post by Shafaet_du » Tue Sep 28, 2010 7:42 pm

some I/O:

Code: Select all

2 100002000003
5 10000005000004000500
6 000061256
7 343447003437
8 034803434
9 90000000009
1 11111111
8 4545238123128234
5 505050505050505
5 101010101010101
5 105050505010
0 0
output:

Code: Select all

10000000003
100000000000400000
125
3434400343
3403434
0
0
45452312312234
0
101010101010101
10000010
very easy problem. just handle leading zeroes carefully. should be ac in less than 10 minutes :).

sms.islam
New poster
Posts: 19
Joined: Sat Oct 10, 2009 10:28 am

Re: Contract revision_11830

Post by sms.islam » Wed Sep 29, 2010 4:52 pm

Thanks.............finally i got AC...........thats a great feelings isn't it?

naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm
Location: CUET,Chittagong,Bangladesh

Re: Contract revision_11830

Post by naseef_07cuet » Wed Dec 01, 2010 12:55 pm

It is a very simple problem.. Happy coding:)
If you have determination, you can do anything you want....:)

User avatar
plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: Contract revision_11830

Post by plamplam » Sun Jun 19, 2011 7:55 am

Some test cases

Code: Select all

1 91029120
3 9192013010391
5 000005555101020
5 5555555550555551555555655554

Code: Select all

902920
91920101091
101020
164
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

sumit saha shawon
New poster
Posts: 19
Joined: Tue Jun 26, 2012 9:19 pm

Re: Contract revision_11830

Post by sumit saha shawon » Wed Aug 08, 2012 10:23 pm

my all input and output correct but why I am getting wa :oops:
My code:

#include<stdio.h>
#include<string.h>
char ch[1500],ar[1500];
int main()
{
int n;
while(scanf("%d",&n)==1)
{
if(n==0)
break;
scanf("%s",&ch);
int i,a=0;
for(i=0; ch!='\0'; i++)
{
if(ch-'0'!=n)
ar[a++]=ch;
}
ar[a]='\0';
if(ar[0]=='0')
{
i=0;
while(ar=='0')
i++;
if(i==a)
{
printf("0\n");

}
else
{
while(ar!='\0')
printf("%c",ar[i++]);
puts("");

}


}
else
{
for(i=0; ar!='\0'; i++)
printf("%c",ar);
puts("");
}



}
return 0;
}

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

Re: Contract revision_11830

Post by brianfry713 » Fri Aug 10, 2012 9:02 am

Doesn't match the sample I/O.
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: Contract revision_11830

Post by uDebug » Sat Mar 08, 2014 2:06 pm

plamplam, Shafaet_du,

Thanks for the great test cases!
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

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

Re: Contract revision_11830

Post by uDebug » Sat Mar 08, 2014 2:10 pm

sumit saha shawon wrote:my all input and output correct but why I am getting wa :oops
Look at Line #11 in your code

Code: Select all

scanf("%s",&ch);
This is probably something you do not want to do.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

axelblaze
New poster
Posts: 34
Joined: Mon Jun 23, 2014 7:45 pm

Re: Contract revision_11830

Post by axelblaze » Mon Aug 11, 2014 10:39 pm

I've tested the Input's by plamplam & Shafaet_du but still getting WA. I have no Idea why...
is it because my output shows exponential numbers??

Code: Select all

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    char num[110],c,ans[110];
    while(cin>>c,cin.ignore(),cin.get(num,100),c!='0'||strcmp(num,"0"))
    {
        int j=0,length=strlen(num);
        for(int i=0;i<length;i++)
            if(num[i]!=c)
            {
                ans[j]=num[i];
                j++;
            }
        ans[j]=0;
        double val=atof(ans);
        cout<<val<<endl;
    }
    return 0;
}

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

Re: Contract revision_11830

Post by lighted » Tue Aug 12, 2014 12:37 pm

is it because my output shows exponential numbers??
Yes. And not only for that reason. This line also won't work.

Code: Select all

double val=atof(ans);
atof returns double value. Double can handle not more that 15 decimal digits of precision. But answer can be up 100 digits.
You can get accepted using c-string. Just remove flawed digit, avoid leading zeroes and print resulting string. :)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

axelblaze
New poster
Posts: 34
Joined: Mon Jun 23, 2014 7:45 pm

Re: Contract revision_11830

Post by axelblaze » Tue Aug 12, 2014 5:42 pm

Thanks lighted but even now I'm getting WA. I've tested the input and it's works correctly... :cry:
here's my new code:

Code: Select all

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    char num[110],c,ans[110];
    while(cin>>c,cin.ignore(),cin.get(num,100),c!='0'||strcmp(num,"0"))
    {
        int j=0,length=strlen(num);
        for(int i=0;i<length;i++)
            if(num[i]!=c&&!(j==0&&num[i]=='0'))
            {
                ans[j]=num[i];
                j++;
            }
        ans[j]=NULL;
        if(ans[0]==NULL) {ans[0]='0';ans[1]=0;}
        cout<<ans<<endl;
    }
    return 0;
}
by the way in case of "1 100000" the output is 0. but in my code::blocks on kubuntu 14.04 machine it shows an empty line. But in a windows machine it shows correctly.
Any Idea why?
I'm am new user of linux karnel so I have no clue.. It maybe is an off-topic but I need to know this. Thanks.. :) :)

Post Reply

Return to “Volume 118 (11800-11899)”