Цветное с палитрой из 256 цветов изображение состоит из миллиона точек. Изображение сжали, уменьшив количество цветов до 32. Какой информационный объем имело изображение, какой получился, во сколько раз он уменьшился? ответьте быстрее
Var s: string; a, b: integer; begin readln(s); if s[1] = 'x' then begin a := StrToInt(s[3]); b := StrToInt(s[5]); if s[2] = '-' then a := -a; writeln(b - a); end else if s[3] = 'x' then begin a := StrToInt(s[1]); b := StrToInt(s[5]); if s[2] = '-' then begin a := -a; b := -b; end; writeln(b - a); end else if s[5] = 'x' then begin a := StrToInt(s[1]); b := StrToInt(s[3]); if s[2] = '-' then b := -b; writeln(a + b); end end.
учтите что никакой защиты от дурака или неверного ввода
public static void main(String[] args) throws java.io.IOException{
int c, n = 0, array[];
while((c = System.in.read())==13 || (47<c && c<58 && (n = n*10+c-48)>-1));
if(25<n || c!=10)return;
array = new int[n];
for(c = 0; c<n; c++){
int d = 0; boolean negative = false;
while((d = System.in.read())!=10)
if(47<d && d<58)array[c] = array[c]*10+d-48;
else if(d==45)negative = true;
if(negative)array[c]*=-1;
}
sortArray(array);
for(c = 0; c<n; c++)System.out.print(array[c]+" ");
}
private static void sortArray(int[] array){
for(int c = 0; c<array.length-1; c++){
int b = c, e;
for(int d = c+1; d<array.length; d++)
if(array[d]>array[b])b=d;
e = array[c];
array[c] = array[b];
array[b] = e;
}
}
}