Rezultati

Up. imeNalogaJezikRezultatČas oddaje
DMT2018 Sveti gral Java 100/100OK 10. maj '18 @ 16:34

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 37,355 MiB 0,000 s OK
#2 5/5 34,488 MiB 0,000 s OK
#3 5/5 39,535 MiB 0,000 s OK
#4 5/5 37,359 MiB 0,000 s OK
#5 5/5 38,332 MiB 0,000 s OK
#6 5/5 36,121 MiB 0,000 s OK
#7 5/5 35,160 MiB 0,000 s OK
#8 5/5 38,031 MiB 0,000 s OK
#9 6/6 39,352 MiB 0,000 s OK
#10 6/6 37,824 MiB 0,000 s OK
#11 6/6 37,371 MiB 0,000 s OK
#12 6/6 36,242 MiB 0,000 s OK
#13 6/6 34,246 MiB 0,000 s OK
#14 6/6 38,902 MiB 0,000 s OK
#15 6/6 37,426 MiB 0,000 s OK
#16 6/6 36,832 MiB 0,000 s OK
#17 6/6 36,641 MiB 0,000 s OK
#18 6/6 36,672 MiB 0,000 s OK

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

public class Gral {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int zacetna=0;
        if(n-81>zacetna)
        {
            zacetna=n-81;
        }
        int counter=0;
        int[] resitve=new int[81];
        int delam;
        while(zacetna<=n)
        {
            delam=zacetna;
            if((delam+vsotaStevk(delam))==n)
            {
                resitve[counter]=delam;
                counter++;
            }

            zacetna++;
        }
        System.out.println(counter);
        for(int i=0;i<counter;i++)
        {
            System.out.println(resitve[i]);
        }
        
        

    }
    public static int vsotaStevk(int a)
    {
        int b=0;
        while(a>0)
        {
            b+=a%10;
            a=a/10;

        }
        return b;

    }
}