Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 5/5 36,008 MiB 0,000 s OK
#2 5/5 36,449 MiB 0,000 s OK
#3 5/5 35,609 MiB 0,000 s OK
#4 5/5 35,230 MiB 0,000 s OK
#5 5/5 33,957 MiB 0,000 s OK
#6 5/5 33,105 MiB 0,000 s OK
#7 5/5 36,117 MiB 0,000 s OK
#8 5/5 32,734 MiB 0,000 s OK
#9 6/6 34,453 MiB 0,000 s OK
#10 6/6 35,313 MiB 0,000 s OK
#11 6/6 35,434 MiB 0,000 s OK
#12 6/6 35,020 MiB 0,000 s OK
#13 6/6 35,059 MiB 0,000 s OK
#14 6/6 35,902 MiB 0,000 s OK
#15 6/6 36,758 MiB 0,000 s OK
#16 6/6 36,355 MiB 0,000 s OK
#17 6/6 35,684 MiB 0,000 s OK
#18 6/6 34,914 MiB 0,000 s OK

Ocenjevani program (n2.java):
import java.io.*;
import java.util.*;
import java.math.*;

public class n2 {
	public static boolean ok(int a,int sum) {
		if(a<=0) {
			return false;
		}
		String s=Integer.toString(a);
		int c=0;
		for(int i=0;i<s.length();i++) {
			c+=s.charAt(i)-'0';
		}
		return a+c==sum;
	}
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int x=Integer.parseInt(in.readLine());
		//Manka pogoj da ne preverjas stevilke v minusu
		int count=0;
		for(int i=x-1;i>x-200;i--) {
			 if(ok(i,x)) {
				 count++;
			 }
		}
		System.out.println(count);
		for(int i=x-200;i<=x;i++) {
			 if(ok(i,x)) {
				 System.out.println(i);
			 }
		}
	}

}