- 1
- 2
- 3
int main() {
for (float n = 0, l = 0, q = scanf("%f", &n), r = n, m = (l + r) / 2; r - l > 0.00001 || 0 * printf("%f", l); m*m <= n ? l = m : r = m, m = (l + r) / 2);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 4
+3
int main() {
for (float n = 0, l = 0, q = scanf("%f", &n), r = n, m = (l + r) / 2; r - l > 0.00001 || 0 * printf("%f", l); m*m <= n ? l = m : r = m, m = (l + r) / 2);
}
Просто бинпоиск в одну строчку)
+142
return st1.empty() || st2.empty() ? st1.empty() && st2.empty() ? 0 : st1.empty() ? st2.gcd() : st1.gcd() : qwer::gcd(st1.gcd(), st2.gcd());
Когда увлёкся условными конструкциями...
+107
var a : int64;
begin
assign(input, 'input.txt'); reset(input);
assign(output, 'output.txt'); rewrite(output);
read(a);
if a=25 then write ('2.7182818284590452353602875');
if a=24 then write ('2.718281828459045235360288');
if a=23 then write ('2.71828182845904523536029');
if a=22 then write ('2.7182818284590452353603');
if a=21 then write ('2.718281828459045235360');
if a=20 then write ('2.71828182845904523536');
if a=19 then write ('2.7182818284590452354');
if a=18 then write ('2.718281828459045235');
if a=17 then write ('2.71828182845904524');
if a=16 then write ('2.7182818284590452');
if a=15 then write ('2.718281828459045');
if a=14 then write ('2.71828182845905');
if a=13 then write ('2.7182818284590');
if a=12 then write ('2.718281828459');
if a=11 then write ('2.71828182846');
if a=10 then write ('2.7182818285');
if a=9 then write ('2.718281828');
if a=8 then write ('2.71828183');
if a=7 then write ('2.7182818');
if a=6 then write ('2.718282');
if a=5 then write ('2.71828');
if a=4 then write ('2.7183');
if a=3 then write ('2.718');
if a=2 then write ('2.72');
if a=1 then write ('2.7');
if a=0 then write ('3')
end.
Вывод числа e с заданной точностью
+88
procedure sr(var q, w: string; j, k: integer);
begin
for j := 1 to 100 do
begin
if ord(q[j]) - ord(w[j]) > 0 then begin for k := 1 to pos(' ', q) do write(q[k]);exit; end
else if ord(q[j]) - ord(w[j]) < 0 then begin for k := 1 to pos(' ', w) do write(w[k]);exit; end;
end;
for k := 1 to pos(' ', w) do write(w[k]);
end;
procedure sr2(var q, w, e, r: string; j, k, p: integer);
begin
for j := 1 to 101 do
begin
if ord(q[j]) - ord(w[j]) > 0 then begin r := q;break; end
else if ord(q[j]) - ord(w[j]) < 0 then begin r := w;break;end;
inc(p);
end;
if p>100 then r:=w;
for j := 1 to 100 do
begin
IF E[J]=' ' Then break;
if ord(e[j]) - ord(r[j]) > 0 then begin for k := 1 to pos(' ', e) do write(e[k]);exit; end
else if ord(e[j]) - ord(r[j]) < 0 then begin for k := 1 to pos(' ', r) do write(r[k]);exit; end;
end;
for k := 1 to pos(' ', r) do write(r[k]);
end;
var
st, a, b, c, rd: string;
i, s: integer;
begin
assign(input, 'input.txt'); reset(input);
assign(output, 'output.txt'); rewrite(output);
read(st);
for i := 1 to 102
do
begin
a := a + ' ';
b := b + ' ';
c := c + ' ';
end;
for i := 1 to length(st) do
if st[i] = ' ' then inc(s)
else
case s of
0: a[i] := st[i];
1: b[i - pos(' ', a)] := st[i];
2: c[i - pos(' ', a) - pos(' ', b)] := st[i];
end;
if (a=b) and (b=c) then for i := 1 to pos(' ', a) do write(a[i])
else if (pos(' ', a) > pos(' ', b)) and (pos(' ', a) > pos(' ', c)) then for i := 1 to pos(' ', a) do write(a[i])
else if (pos(' ', b) > pos(' ', a)) and (pos(' ', b) > pos(' ', c)) then for i := 1 to pos(' ', b) do write(b[i])
else if (pos(' ', c) > pos(' ', b)) and (pos(' ', c) > pos(' ', a)) then for i := 1 to pos(' ', c) do write(c[i])
else if (pos(' ', a) = pos(' ', b)) and (pos(' ', b) = pos(' ', c)) then sr2(a, b, c, rd, 0, 0, 0)
else if pos(' ', a) = pos(' ', b) then sr(a, b, 0, 0)
else if pos(' ', c) = pos(' ', b) then sr(c, b, 0, 0)
else if pos(' ', a) = pos(' ', c) then sr(a, c, 0, 0);
end.
Выбор максимума из 3 целых длинных чисел