Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ASMx64-2018 Sveti gral C++ 100/100OK 10. maj '18 @ 17:32

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 3,395 MiB 0,000 s OK
#2 5/5 3,395 MiB 0,004 s OK
#3 5/5 3,168 MiB 0,004 s OK
#4 5/5 3,160 MiB 0,000 s OK
#5 5/5 3,398 MiB 0,000 s OK
#6 5/5 3,461 MiB 0,004 s OK
#7 5/5 3,395 MiB 0,000 s OK
#8 5/5 3,457 MiB 0,004 s OK
#9 6/6 3,219 MiB 0,000 s OK
#10 6/6 3,223 MiB 0,000 s OK
#11 6/6 3,398 MiB 0,000 s OK
#12 6/6 3,398 MiB 0,000 s OK
#13 6/6 3,395 MiB 0,004 s OK
#14 6/6 3,398 MiB 0,004 s OK
#15 6/6 3,227 MiB 0,000 s OK
#16 6/6 3,461 MiB 0,000 s OK
#17 6/6 3,461 MiB 0,004 s OK
#18 6/6 3,398 MiB 0,004 s OK

Ocenjevani program (SvetiGral.cpp):
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
long long n;

bool isOK(long long a) {
	long long sum = a;
	while (a > 0 && sum <= n) {
		sum += a % 10;
		a /= 10;
	}
	return sum == n;
}

int main() {
	cin >> n;
	vector<long long>resitev;
	long long SM = n - floor(log10(n) + 1) * 9;
	//cout << SM << endl;
	for (int i = SM; i <= n; i++) {
		if (isOK(i)) resitev.push_back(i);
	}

	cout << resitev.size()<<endl;
	for (int i = 0; i < resitev.size(); i++) {
		cout << resitev[i] << endl;
	}
	//system("pause");


	return 0;
}