Rezultati

Up. imeNalogaJezikRezultatČas oddaje
lml-2018 Sveti gral Java 100/100OK 10. maj '18 @ 17:56

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 34,867 MiB 0,000 s OK
#2 5/5 36,266 MiB 0,000 s OK
#3 5/5 38,980 MiB 0,000 s OK
#4 5/5 38,980 MiB 0,000 s OK
#5 5/5 39,148 MiB 0,000 s OK
#6 5/5 34,547 MiB 0,000 s OK
#7 5/5 37,566 MiB 0,000 s OK
#8 5/5 36,070 MiB 0,000 s OK
#9 6/6 34,047 MiB 0,000 s OK
#10 6/6 39,008 MiB 0,000 s OK
#11 6/6 37,332 MiB 0,000 s OK
#12 6/6 36,277 MiB 0,000 s OK
#13 6/6 37,457 MiB 0,000 s OK
#14 6/6 38,262 MiB 0,000 s OK
#15 6/6 38,934 MiB 0,000 s OK
#16 6/6 36,039 MiB 0,000 s OK
#17 6/6 38,836 MiB 0,000 s OK
#18 6/6 36,953 MiB 0,000 s OK

Ocenjevani program (Gral.java):
import java.util.*;

public class Gral
{
    public static void main(String[]args)
    {
        Scanner skan = new Scanner(System.in);
        int n = skan.nextInt();
        List<Integer> list = new ArrayList<Integer>();
        int k = 0;
        
        if(n >= 81)
        {    
            for(int i = n - 81; i < n; i++)
            {
                if(i + stevke(i) == n)
                {
                   list.add(i);
                   k++;
                }
            }
        }
        else
        {
            for(int i = 1; i < n; i++)
            {
                if(i + stevke(i) == n)
                {
                    list.add(i); 
                    k++;
                }
            }
        }

        Collections.sort(list);
        System.out.println(k);

        for(int i = 0; i < list.size(); i++)
        {
            System.out.println(list.get(i));
        }
    }
    public static int stevke(int x)
    {
        int y = x; 
        int result = 0;

        while(y != 0)
        {
            result += y % 10;
            y = y/10;
        }

        return result;
    }
}