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

Anastas Easytask!!!!!! [7] // Problem 1206. Sum of Digits of the Sum of Numbers 1 Sep 2007 14:07
Just use long arithmetics and calculate 36*pow(55,k-1);
jagatsastry Re: Easytask!!!!!! [4] // Problem 1206. Sum of Digits of the Sum of Numbers 16 Oct 2007 00:45
How did u get the formula
jagatsastry Re: Easytask!!!!!! [3] // Problem 1206. Sum of Digits of the Sum of Numbers 16 Oct 2007 01:02
What are the libraries and functions u use for long arithmetic in c++.
There are no such libraries! You must write long arithmetics by yourself ;)
Orlangur [KNU] Or find somewhere... (+) [1] // Problem 1206. Sum of Digits of the Sum of Numbers 24 Feb 2008 01:22
Thank finaly something extra ordinary good.
Thanks allot. I was searching for this for so long time. Thanks, thanks, thanks...
IgorKoval(from Pskov) Re: Easytask!!!!!! [1] // Problem 1206. Sum of Digits of the Sum of Numbers 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
Thanks for your code.