11952 - Arithmetic

All about problems in Volume 119. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
jurajz
Learning poster
Posts: 69
Joined: Sat Sep 02, 2006 7:30 pm
Location: Slovakia

11952 - Arithmetic

Post by jurajz » Fri Apr 15, 2011 11:00 pm

Hello,

I think, that this problem is not difficult, but it have many WA's (me too). Are there some critical test cases? I want ask for sentence "in base 1 character '1' is used as only possible digit". As I know, number in base b can have digits from 0 to b-1, that means no '1' can be in base-1 number.

What is correct output for this input?

Code: Select all

6
0 + 0 = 0
0 + 5 = 5
2 + 2 = 4
0 + 6 = 7
1 + 1 = 1
1 + 1 = 2
I think, that it is

Code: Select all

1
6
5
0
0
3
Thanks in advance!

stencel
New poster
Posts: 8
Joined: Tue Oct 19, 2010 10:21 am

Re: 11952 - Arithmetic

Post by stencel » Sat Apr 16, 2011 12:01 am

The task description is clear in case of 1-based system. The only allowable digit is 1.

durjay
New poster
Posts: 13
Joined: Tue Oct 06, 2009 5:09 pm
Location: ctg

Re: 11952 - Arithmetic

Post by durjay » Wed May 11, 2011 9:51 pm

I also getting wa in this problem.
can anyone give critical input output for this problem???? :(

Najmuzzaman
New poster
Posts: 3
Joined: Mon May 23, 2011 1:44 pm

Re: 11952 - Arithmetic

Post by Najmuzzaman » Wed Jun 15, 2011 4:05 am

Code: Select all

#include <stdio.h>
typedef long long ll;
int convert(int n,int b)
{
    int p=1,sum=0;
    while(n)
    {
        sum+=((n%10)*(p));
        n/=10;
        p*=b;
    }
    return sum;
}

int high(int n)
{
    int hig=0,a;
    while(n)
    {
        a=n%10;
        if(hig<a)
            hig=a;
        n/=10;
    }
    return hig;
}
int main()
{
    int t,a,b,c,max,d,i;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d + %d = %d",&a,&b,&c);
        max=high(a);
        d=high(b);
        if(max<d)
            max=d;
        d=high(c);
        if(max<d)
            max=d;
        bool flag=1;
        for(i=max+1;i<101;i++)
        {
            if(convert(a,i)+convert(b,i)==convert(c,i))
            {
                printf("%d\n",i);
                flag=0;
                break;
            }
        }
        if(flag)
            printf("0\n");
    }
    return 0;
}
I get WA on this code
Plz any one help me

mehdiii
New poster
Posts: 9
Joined: Fri Nov 02, 2012 1:35 pm

Re: 11952 - Arithmetic

Post by mehdiii » Thu Mar 28, 2013 1:01 am

Just check for bases up to 50, and the only special case is when base = 1 (which is clearly explained in the problem statement).

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

Re: 11952 - Arithmetic

Post by brianfry713 » Thu Mar 28, 2013 8:46 pm

You only need to check up to base 18. Input: 9 + 9 = 10, AC output: 18.
Check input and AC output for thousands of problems on uDebug!

t.tahasin
New poster
Posts: 38
Joined: Tue May 28, 2013 11:21 pm

Re: 11952 - Arithmetic

Post by t.tahasin » Mon Jul 01, 2013 11:15 am

Can't figure out the problem. Always getting WA. What will happen for
1 + 1 = 1
what are the special cases?
Here is my code. Please help.

Code: Select all

Deleted after ac.
Last edited by t.tahasin on Tue Jul 02, 2013 8:11 am, edited 1 time in total.

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

Re: 11952 - Arithmetic

Post by brianfry713 » Tue Jul 02, 2013 1:18 am

Input:

Code: Select all

2
1 + 1 = 1
1 + 1 = 11
AC output:

Code: Select all

0
1
Check input and AC output for thousands of problems on uDebug!

t.tahasin
New poster
Posts: 38
Joined: Tue May 28, 2013 11:21 pm

Re: 11952 - Arithmetic

Post by t.tahasin » Tue Jul 02, 2013 8:12 am

@brianfry713: Thank you. I got accepted. :)

Repon kumar Roy
Learning poster
Posts: 96
Joined: Tue Apr 23, 2013 12:54 pm

Re: 11952 - Arithmetic

Post by Repon kumar Roy » Wed Aug 20, 2014 12:37 pm

Got AC ..
Thanks brain fry .
Last edited by Repon kumar Roy on Wed Aug 20, 2014 10:35 pm, edited 1 time in total.

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

Re: 11952 - Arithmetic

Post by brianfry713 » Wed Aug 20, 2014 9:03 pm

Input:
1
10 + 0 = 1

output should be 0
Check input and AC output for thousands of problems on uDebug!

anacharsis
Learning poster
Posts: 69
Joined: Mon Feb 09, 2015 1:56 am

Re: 11952 - Arithmetic

Post by anacharsis » Sun Sep 06, 2015 11:23 pm

Some I/O

In:

Code: Select all

212
111 + 11111 = 11111111
666 + 141 = 807
295 + 147 = 442
260 + 168 = 408
571 + 373 = 904
495 + 90 = 545
87 + 874 = 961
699 + 270 = 969
138 + 449 = 57
273 + 469 = 720
762 + 81 = 833
452 + 248 = 700
22 + 857 = 880
177 + 280 = 407
38 + 325 = 360
573 + 404 = 977
9 + 18 = 1
8 + 10 = 18
9 + 9 = 13
2 + 17 = 19
5 + 9 = 10
6 + 10 = 16
1 + 3 = 4
0 + 16 = 16
9 + 0 = 9
2 + 4 = 6
4 + 2 = 10
5 + 10 = 15
17 + 19 = 2
7 + 4 = 11
7 + 6 = 14
14 + 2 = 16
6 + 2 = 11
6 + 6 = 13
2 + 17 = 19
6 + 7 = 10
4 + 2 = 10
9 + 10 = 19
7 + 6 = 11
2 + 4 = 10
5 + 7 = 11
1 + 11 = 12
11 + 4 = 15
3 + 9 = 11
3 + 6 = 12
7 + 7 = 11
2 + 3 = 11
6 + 0 = 6
4 + 3 = 7
8 + 9 = 15
2 + 7 = 10
6 + 9 = 13
1 + 5 = 6
9 + 6 = 10
3 + 13 = 16
3 + 12 = 15
12 + 7 = 19
9 + 7 = 13
1 + 2 = 10
8 + 5 = 14
14 + 4 = 18
4 + 14 = 18
4 + 6 = 11
19 + 8 = 1
1 + 2 = 10
5 + 5 = 11
3 + 0 = 3
5 + 4 = 9
5 + 10 = 15
7 + 1 = 10
4 + 5 = 10
3 + 1 = 4
2 + 1 = 10
7 + 8 = 16
2 + 2 = 11
10 + 6 = 16
4 + 4 = 12
6 + 4 = 10
18 + 1 = 19
7 + 19 = 1
9 + 8 = 17
6 + 3 = 9
6 + 6 = 12
8 + 10 = 18
8 + 18 = 1
5 + 14 = 19
3 + 9 = 10
8 + 8 = 14
6 + 4 = 10
9 + 3 = 10
3 + 16 = 19
1 + 2 = 3
10 + 9 = 19
8 + 8 = 13
8 + 5 = 13
8 + 6 = 12
2 + 11 = 13
11 + 5 = 16
8 + 9 = 17
2 + 5 = 11
4 + 2 = 11
4 + 11 = 15
3 + 13 = 16
18 + 9 = 1
13 + 0 = 13
2 + 5 = 11
2 + 9 = 10
1 + 1 = 10
8 + 10 = 18
11 + 7 = 18
5 + 5 = 12
8 + 4 = 10
1 + 4 = 5
8 + 7 = 11
1 + 10 = 11
4 + 3 = 12
19 + 19 = 2
13 + 0 = 13
4 + 14 = 18
5 + 6 = 12
7 + 5 = 11
8 + 9 = 13
7 + 8 = 14
6 + 12 = 18
4 + 6 = 12
4 + 5 = 13
19 + 18 = 2
5 + 11 = 16
9 + 1 = 10
3 + 6 = 12
9 + 6 = 11
5 + 9 = 10
3 + 4 = 12
19 + 18 = 2
7 + 8 = 10
0 + 16 = 16
1 + 7 = 8
2 + 5 = 11
8 + 4 = 11
6 + 12 = 18
1 + 4 = 5
4 + 9 = 12
9 + 8 = 14
19 + 9 = 1
3 + 16 = 19
7 + 4 = 13
6 + 3 = 12
9 + 6 = 14
19 + 18 = 2
8 + 4 = 11
13 + 1 = 14
7 + 6 = 10
5 + 9 = 10
13 + 2 = 15
0 + 5 = 5
7 + 8 = 12
11 + 7 = 18
9 + 7 = 15
9 + 7 = 13
7 + 6 = 12
8 + 1 = 9
2 + 0 = 2
18 + 18 = 2
2 + 9 = 10
1 + 8 = 9
5 + 10 = 15
3 + 4 = 7
1 + 4 = 5
3 + 8 = 10
5 + 9 = 12
2 + 14 = 16
7 + 7 = 15
9 + 3 = 12
3 + 4 = 12
5 + 7 = 14
4 + 9 = 13
6 + 9 = 10
3 + 4 = 7
9 + 2 = 11
7 + 8 = 16
9 + 17 = 1
7 + 7 = 11
9 + 17 = 1
9 + 4 = 13
9 + 6 = 10
7 + 6 = 12
9 + 9 = 17
7 + 7 = 14
5 + 7 = 13
5 + 8 = 10
0 + 15 = 15
9 + 6 = 12
6 + 1 = 10
14 + 3 = 17
2 + 5 = 7
5 + 9 = 11
0 + 6 = 6
19 + 8 = 1
12 + 1 = 13
6 + 8 = 15
4 + 3 = 11
8 + 6 = 10
11 + 3 = 14
6 + 12 = 18
17 + 2 = 19
17 + 2 = 19
8 + 10 = 18
9 + 7 = 16
2 + 8 = 10
9 + 8 = 15
3 + 2 = 5
2 + 0 = 2
AC Out:

Code: Select all

1
10
10
12
14
14
10
10
18
12
11
10
9
15
13
10
18
9
15
10
14
7
5
7
10
7
6
6
17
10
9
7
7
9
10
13
6
10
12
6
11
3
6
11
7
13
4
7
8
12
9
12
7
15
7
6
10
13
3
9
9
9
9
18
3
9
4
10
6
8
9
5
3
9
3
7
6
10
10
17
10
10
10
9
17
10
12
12
10
12
10
4
10
13
10
12
4
7
10
6
5
6
7
18
4
6
11
2
9
9
8
12
6
14
2
5
19
4
9
9
11
14
11
9
8
6
18
7
10
7
14
14
5
18
15
7
9
6
11
9
6
11
13
19
10
8
7
11
18
11
5
13
14
6
6
13
9
11
13
11
10
3
17
11
10
6
8
6
11
12
7
9
10
5
8
10
15
8
10
9
17
13
17
10
15
11
11
10
9
13
6
13
7
8
8
13
7
18
4
9
6
14
5
9
10
10
9
10
10
12
6
3

Post Reply

Return to “Volume 119 (11900-11999)”