COUNTCBG - COUNT N

Tác giả: ladpro98

Ngôn ngữ: Pascal

program countcbg;
uses    math;
const   fi='';
var     n,x:int64;
        res,i:longint;
        k:real;
        inp:text;
begin
        assign(inp,fi);
        reset(inp);
        while not eof(inp) do
        begin
                readln(inp,n);
                res:=0;
                k:=(sqrt(8*n+1)-1)/2;
                if trunc(k)=k then k:=k-1;
                for i:=1 to trunc(k) do
                begin
                        x:=2*n-i*(i+1);
                        if x mod (2*(i+1)) = 0 then
                        inc(res);
                end;
                writeln(res);
        end;
end.

Download