ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1206. Sum of Digits of the Sum of Numbers

Mansurov Artur non correct statement? [2] // Problem 1206. Sum of Digits of the Sum of Numbers 9 Jul 2008 10:22
for K=2 we can get 1980 only if we assume that pairs
A=12 B=12
A=12 B=12
are two different pairs like
A=11 B=12
A=12 B=11
Chmel_Tolstiy Re: non correct statement? [1] // Problem 1206. Sum of Digits of the Sum of Numbers 9 Jul 2008 14:44
I think u are not right.
Yes, see this programm:

#include <iostream>
#include <math.h>

using namespace std;

int Sum (int n)
{
    int s=0;
    while (n)
    {
        s+=n%10;
        n/=10;
    }
    return s;
}

int main()
{
    int k=0;
    for (int i=10; i<100; i++)
    {
        for (int j=10; j<100; j++)
        {
            if (Sum(i)+Sum(j)==Sum(i+j))
            {
                k++; cout<<i<<" "<<j<<"\n";
            }
        }
    }
            cout<<k;
    return 0;
}

It returns 1980, but you can easily see that if i=j this pair wasn't counted twice