Rezultati

Up. imeNalogaJezikRezultatČas oddaje
jam-2018 Sveti gral Java 100/100OK 10. maj '18 @ 16:52

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 33,758 MiB 0,000 s OK
#2 5/5 35,031 MiB 0,000 s OK
#3 5/5 37,047 MiB 0,000 s OK
#4 5/5 38,766 MiB 0,000 s OK
#5 5/5 38,602 MiB 0,000 s OK
#6 5/5 36,469 MiB 0,000 s OK
#7 5/5 34,309 MiB 0,000 s OK
#8 5/5 36,238 MiB 0,000 s OK
#9 6/6 39,344 MiB 0,000 s OK
#10 6/6 39,207 MiB 0,000 s OK
#11 6/6 38,992 MiB 0,000 s OK
#12 6/6 35,676 MiB 0,000 s OK
#13 6/6 33,699 MiB 0,000 s OK
#14 6/6 39,320 MiB 0,000 s OK
#15 6/6 38,172 MiB 0,000 s OK
#16 6/6 37,840 MiB 0,000 s OK
#17 6/6 35,031 MiB 0,000 s OK
#18 6/6 36,695 MiB 0,000 s OK

Ocenjevani program (Main.java):
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static int sum(int n){
        if(n == 0)return 0;
        return n%10+sum(n/10);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        ArrayList<Integer> list = new ArrayList<Integer>();

        int n = sc.nextInt();
        for(int x = Math.max(n - 82, 0); x <= n; x++){
            if(n == x + sum(x)){
                list.add(new Integer(x));
            }
        }

        System.out.println(list.size());
        for(int i = 0; i < list.size(); i++){
            System.out.println(list.get(i));
        }
    }
}