COUNTCBG - COUNT N

Tác giả: ll931110

Ngôn ngữ: Pascal

Program COUNTCBG;
        Const
                input  = '';
                output = '';
        Var
                a,num: array[1..100] of longint;
                    n: integer;

Procedure init;
          Var
                f: text;
          Begin
                Assign(f, input);
                        Reset(f);

                n:= 0;
                While not Eof(f) do
                        Begin
                                inc(n);
                                Readln(f, a[n]);
                        End;

                Close(f);
          End;

Procedure solve;
          Var
                i,j,s: longint;
          Begin
                Fillchar(num, sizeof(num), 0);
                s:= 1;

                For i:= 2 to 50000 do
                        Begin
                                s:= s + i;
                                For j:= 1 to n do
                                        if (a[j] >= s) and ((a[j] - s) mod i = 0) then inc(num[j]);
                        End;
          End;

Procedure printresult;
          Var
                i: integer;
                f: text;
          Begin
                Assign(f, output);
                        Rewrite(f);

                For i:= 1 to n do writeln(f, num[i]);
                Close(f);
          End;

Begin
        init;
        solve;
        printresult;
End.

Download