11830 - Contract Revision
Moderator: Board moderators
11830 - Contract Revision
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....................
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....................
Re: Contract revision_11830
You don't have answer for 7 777 in your output.
Re: Contract revision_11830
[]
point taken.i missed it.It will be
7 777------------>1
now please help me through it
[]
point taken.i missed it.It will be
7 777------------>1
now please help me through it
[]
Re: Contract revision_11830
7 777 should be 0
-
- Experienced poster
- Posts: 147
- Joined: Mon Jun 07, 2010 11:43 am
- Location: University Of Dhaka,Bangladesh
- Contact:
Re: Contract revision_11830
some I/O:
output:
very easy problem. just handle leading zeroes carefully. should be ac in less than 10 minutes
.
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
Code: Select all
10000000003
100000000000400000
125
3434400343
3403434
0
0
45452312312234
0
101010101010101
10000010

UVa stats: http://felix-halim.net/uva/hunting.php?id=63448
My blog on programming: http://www.shafaetsplanet.com/planetcoding/
My blog on programming: http://www.shafaetsplanet.com/planetcoding/
Re: Contract revision_11830
Thanks.............finally i got AC...........thats a great feelings isn't it?
-
- Learning poster
- Posts: 62
- Joined: Sat Nov 21, 2009 10:17 pm
- Location: CUET,Chittagong,Bangladesh
Re: Contract revision_11830
It is a very simple problem.. Happy coding:)
If you have determination, you can do anything you want....

Re: Contract revision_11830
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
-
- New poster
- Posts: 19
- Joined: Tue Jun 26, 2012 9:19 pm
Re: Contract revision_11830
my all input and output correct but why I am getting wa
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;
}

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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: Contract revision_11830
Doesn't match the sample I/O.
Check input and AC output for thousands of problems on uDebug!
Re: Contract revision_11830
Look at Line #11 in your codesumit saha shawon wrote:my all input and output correct but why I am getting waops
Code: Select all
scanf("%s",&ch);
Re: Contract revision_11830
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??
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;
}
Re: Contract revision_11830
Yes. And not only for that reason. This line also won't work.is it because my output shows exponential numbers??
Code: Select all
double val=atof(ans);
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
Re: Contract revision_11830
Thanks lighted but even now I'm getting WA. I've tested the input and it's works correctly...
here's my new code:
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..


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;
}
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..

