Page 2 of 2

Re: Contract revision_11830

Posted: Tue Aug 12, 2014 6:46 pm
by lighted
You can change reading to

Code: Select all

    while(scanf(" %c %s", &c, num) == 2)
    {
        if (c=='0' &&  !strcmp(num,"0")) break;
I don't use linux.

Re: Contract revision_11830

Posted: Tue Aug 12, 2014 8:22 pm
by axelblaze
Thanks I got ac..
But what was wrong with "while(cin>>c,cin.ignore(),cin.get(num,100),c!='0'||strcmp(num,"0"))" statement anyway..?
It was taking input and terminating just fine.
I'm just curious... :wink: :wink:

Re: Contract revision_11830

Posted: Sat Aug 16, 2014 1:26 am
by brianfry713
It looks like there is an N in the judge's input that is one character longer than it should be.
If you change your old code to: cin.get(num,101) it will get AC.

Re: Contract revision_11830

Posted: Sun Aug 17, 2014 8:18 pm
by axelblaze
Thanks brianfry. I got ac with that... I didn't know that judge has this kind of inputs...

Re: Contract revision_11830

Posted: Thu Aug 21, 2014 10:56 pm
by RedCode119
I'm getting WS but can't find out my problem. here's the code ..

Code: Select all

#include <iostream>

using namespace std;

int main()
{
    long long int a,b,i,add,sep,mul;
    while(cin>>a>>b)
    {
        if(a==0 && b==0)
            break;
        mul=1;
        add=0;
        for(i=b;i!=0;i/=10)
        {
           sep=i%10;
           if(sep!=a)
           {
               add=(sep*mul)+add;
               mul*=10;
           }
        }
        cout<<add<<endl;
    }
    return 0;
}

Re: Contract revision_11830

Posted: Sat Aug 23, 2014 1:37 pm
by lighted
Each line contains two integers D and N ( 1<= D <= 9 and 1 <= N < 10^100 )
Second integer can be 10^100. long long is not enough, it handles only 19-20 digits. Use string. :)