1 solutions

  • 0
    @ 2024-12-10 23:55:33

    C++ :

    #include <iostream>
    using namespace std;
    int a,b;
    int main()
    {
        cin>>a>>b;
        int c;
        c=b-2;
        b=0;
        for (int i=1;i<=c;i++) b+=i;
        c=a;a=1;
        for (int i=1;i<=c;i++) a+=i;
        cout<<(a-b);
        return 0;
    }
    

    Pascal :

    var  n,p,t,i:longint;
    begin
      readln(n,p);
      t:=2*p;
      for i:=p+1 to n do
        t:=t+i;
      writeln(t);
    end.
    
    • 1

    Information

    ID
    644
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By