Rezultati

Up. imeNalogaJezikRezultatČas oddaje
tabs-2018 Sveti gral C++ 100/100OK 10. maj '18 @ 16:55

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 3,430 MiB 0,004 s OK
#2 5/5 3,332 MiB 0,004 s OK
#3 5/5 3,422 MiB 0,000 s OK
#4 5/5 3,336 MiB 0,004 s OK
#5 5/5 3,336 MiB 0,000 s OK
#6 5/5 3,430 MiB 0,004 s OK
#7 5/5 3,336 MiB 0,004 s OK
#8 5/5 3,426 MiB 0,000 s OK
#9 6/6 3,336 MiB 0,004 s OK
#10 6/6 3,332 MiB 0,000 s OK
#11 6/6 3,430 MiB 0,004 s OK
#12 6/6 3,328 MiB 0,004 s OK
#13 6/6 3,430 MiB 0,004 s OK
#14 6/6 3,426 MiB 0,004 s OK
#15 6/6 3,332 MiB 0,004 s OK
#16 6/6 3,336 MiB 0,004 s OK
#17 6/6 3,426 MiB 0,004 s OK
#18 6/6 3,328 MiB 0,004 s OK

Ocenjevani program (main.cpp):
#include <algorithm>
#include <array>
#include <complex>
#include <cmath>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

int n;
vector<int> v;
vector<int> :: iterator it;

int main()
{
    cin>>n;
    
    v.reserve(n);
    int found = 0;
    int i=(n-500);
    if(i<0) i = 1;
    if(n%10==0) i++;
    
    int curr = i;
    int st = i;
    for(; curr > 0; curr/=10)
    {
		st+= curr%10;
		//cout<<curr<<endl;
	}
	st += curr%10;
	//cout<<st<<" "<<i<<" "<<n<<endl;
	if(st == 2 && i == 1) st = 0;
    
    if(i>1) i++;
    
    for(; i<(n+500); i++)
    {
		bool visited = false;
		for(int exp = 10; exp >= 0; exp--)
		{
			if(i%(int)pow(10,exp) == 0)
			{
				st += -7-(9*(exp-1));
				visited = true;
				break;
			}
		}
		if(!visited) st+= 2;
		if(n == st)
		{
			found++;
			v.push_back(i);
			//cout<<" TEST " << endl;
		}
		
	}
	
	cout<<found<<endl;
	for(it = v.begin(); it != v.end(); ++it)
		cout<<*it<<endl;
   
	return 0;
}