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

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 6:46 pm

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.
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 8:22 pm

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:

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

Re: Contract revision_11830

Post by brianfry713 » Sat Aug 16, 2014 1:26 am

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.
Check input and AC output for thousands of problems on uDebug!

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

Re: Contract revision_11830

Post by axelblaze » Sun Aug 17, 2014 8:18 pm

Thanks brianfry. I got ac with that... I didn't know that judge has this kind of inputs...

RedCode119
New poster
Posts: 13
Joined: Tue Jul 08, 2014 7:14 pm

Re: Contract revision_11830

Post by RedCode119 » Thu Aug 21, 2014 10:56 pm

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

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

Re: Contract revision_11830

Post by lighted » Sat Aug 23, 2014 1:37 pm

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. :)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

Post Reply

Return to “Volume 118 (11800-11899)”