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

Easytask!!!!!!
Posted by Anastas 1 Sep 2007 14:07
Just use long arithmetics and calculate 36*pow(55,k-1);
Re: Easytask!!!!!!
Posted by jagatsastry 16 Oct 2007 00:45
How did u get the formula
Re: Easytask!!!!!!
Posted by jagatsastry 16 Oct 2007 01:02
What are the libraries and functions u use for long arithmetic in c++.
Re: Easytask!!!!!!
Posted by MAT 23 Feb 2008 23:52
There are no such libraries! You must write long arithmetics by yourself ;)
Re: Or find somewhere... (+)
Posted by Aleksa_Markoni 27 Nov 2008 03:44
Thank finaly something extra ordinary good.
Thanks allot. I was searching for this for so long time. Thanks, thanks, thanks...
Re: Easytask!!!!!!
Posted by IgorKoval(from Pskov) 23 Nov 2011 03:01
This program explain how get 36 and 55.


#include <iostream>
using namespace std;

__int64 s( __int64 x ){
    __int64 ans = 0;
    while( x ){
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

int main(){
    __int64 kol = 0;
    for( __int64 i = 0; i <= 9; ++i ){
    for( __int64 j = 0; j <= 9; ++j ){
            if( s(i+j) == s(i)+s(j) && i+j<=9 ){
                cout << "    " << i << " " << j << "        s=" << s(i+j) << endl;
                ++kol;
            }
        }
        cout << "-------------------------" << endl;
    }
    cout
    << "kol = "
    << kol << endl;

    kol = 0;
    for( __int64 i = 1; i <= 9; ++i ){// последний разряд без нулей т.к. число must be без ведущих нулей
    for( __int64 j = 1; j <= 9; ++j ){
            if( s(i+j) == s(i)+s(j) && i+j<=9 ){
                cout << "    " << i << " " << j << "        s=" << s(i+j) << endl;
                ++kol;
            }
        }
        cout << "-------------------------" << endl;
    }
    cout
        << "kol = "
        << kol << endl;
    return 0;
}

Edited by author 23.11.2011 03:11

Edited by author 23.11.2011 03:12

Edited by author 23.11.2011 03:12
Re: Easytask!!!!!!
Posted by Pegasus 15 Oct 2012 20:41
Thanks for your code.