Page 1 of 2
11830 - Contract Revision
Posted: Sat Sep 25, 2010 6:17 pm
by sms.islam
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....................
Re: Contract revision_11830
Posted: Sun Sep 26, 2010 2:46 am
by pdwd
You don't have answer for 7 777 in your output.
Re: Contract revision_11830
Posted: Mon Sep 27, 2010 2:31 pm
by sms.islam
[]
point taken.i missed it.It will be
7 777------------>1
now please help me through it
[]
Re: Contract revision_11830
Posted: Tue Sep 28, 2010 3:21 am
by pdwd
7 777 should be 0
Re: Contract revision_11830
Posted: Tue Sep 28, 2010 7:42 pm
by Shafaet_du
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

.
Re: Contract revision_11830
Posted: Wed Sep 29, 2010 4:52 pm
by sms.islam
Thanks.............finally i got AC...........thats a great feelings isn't it?
Re: Contract revision_11830
Posted: Wed Dec 01, 2010 12:55 pm
by naseef_07cuet
It is a very simple problem.. Happy coding:)
Re: Contract revision_11830
Posted: Sun Jun 19, 2011 7:55 am
by plamplam
Some test cases
Code: Select all
1 91029120
3 9192013010391
5 000005555101020
5 5555555550555551555555655554
Re: Contract revision_11830
Posted: Wed Aug 08, 2012 10:23 pm
by sumit saha shawon
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;
}
Re: Contract revision_11830
Posted: Fri Aug 10, 2012 9:02 am
by brianfry713
Doesn't match the sample I/O.
Re: Contract revision_11830
Posted: Sat Mar 08, 2014 2:06 pm
by uDebug
plamplam, Shafaet_du,
Thanks for the great test cases!
Re: Contract revision_11830
Posted: Sat Mar 08, 2014 2:10 pm
by uDebug
sumit saha shawon wrote:my all input and output correct but why I am getting wa

ops
Look at Line #11 in your code
This is probably something you do
not want to do.
Re: Contract revision_11830
Posted: Mon Aug 11, 2014 10:39 pm
by axelblaze
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;
}
Re: Contract revision_11830
Posted: Tue Aug 12, 2014 12:37 pm
by lighted
is it because my output shows exponential numbers??
Yes. And not only for that reason. This line also won't work.
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.

Re: Contract revision_11830
Posted: Tue Aug 12, 2014 5:42 pm
by axelblaze
Thanks lighted but even now I'm getting WA. I've tested the input and it's works correctly...
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..
