Rezultati

Up. imeNalogaJezikRezultatČas oddaje
marko Sveti gral C++ 100/100OK 10. maj '18 @ 19:30

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 3,105 MiB 0,004 s OK
#2 5/5 3,105 MiB 0,004 s OK
#3 5/5 3,035 MiB 0,004 s OK
#4 5/5 3,105 MiB 0,004 s OK
#5 5/5 3,098 MiB 0,004 s OK
#6 5/5 3,168 MiB 0,000 s OK
#7 5/5 3,098 MiB 0,004 s OK
#8 5/5 3,168 MiB 0,004 s OK
#9 6/6 3,035 MiB 0,000 s OK
#10 6/6 3,105 MiB 0,000 s OK
#11 6/6 3,102 MiB 0,004 s OK
#12 6/6 3,035 MiB 0,004 s OK
#13 6/6 3,035 MiB 0,004 s OK
#14 6/6 3,035 MiB 0,004 s OK
#15 6/6 3,035 MiB 0,000 s OK
#16 6/6 3,160 MiB 0,004 s OK
#17 6/6 3,035 MiB 0,000 s OK
#18 6/6 3,035 MiB 0,004 s OK

Ocenjevani program (main.cpp):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int sumOfDigits(long long x)
{
    int sum = 0;
    while (x > 0)
    {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main()
{
    long long N;
    cin >> N;
    vector<long long> lista;
    for(long long i = N; i >= 0; i--){
        if(i < N - 100)
            break;
        if (i + sumOfDigits(i) == N){
            lista.push_back(i);
        }
    }
    sort(lista.begin(), lista.end());
    cout << lista.size() << endl;
    for(int i = 0; i < lista.size(); i++){
        cout << lista[i] << endl;
    }
    return 0;
}