Submission #12125241


Source Code Expand

Copy
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n,k;
  cin>>n>>k;
  int ans=0;
  for(int i=k;i<=n+1;i++)
  {
    int z=((n*(n+1))/2)%mod;
    z-=(((n-i)*(n-i+1))/2)%mod;
    z+=mod;
    z%=mod;
    int z2=((i*(i-1))/2-1+mod)%mod;
    ans+=(z-z2+mod)%mod;
    ans%=mod;
  }
  cout<<ans;
 
// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}

Submission Info

Submission Time
Task D - Sum of Large Numbers
User babayaga
Language C++ (GCC 9.2.1)
Score 400
Code Size 1305 Byte
Status AC
Exec Time 7 ms
Memory 3804 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, max_01, max_02, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 AC 5 ms 3780 KB
hand_02 AC 2 ms 3796 KB
max_01 AC 6 ms 3780 KB
max_02 AC 6 ms 3712 KB
random_01 AC 3 ms 3656 KB
random_02 AC 2 ms 3804 KB
random_03 AC 2 ms 3776 KB
random_04 AC 2 ms 3756 KB
random_05 AC 2 ms 3788 KB
random_06 AC 2 ms 3780 KB
random_07 AC 7 ms 3704 KB
random_08 AC 3 ms 3764 KB
random_09 AC 4 ms 3800 KB
random_10 AC 2 ms 3664 KB
random_11 AC 2 ms 3756 KB
random_12 AC 2 ms 3664 KB
sample_01 AC 2 ms 3764 KB
sample_02 AC 3 ms 3800 KB
sample_03 AC 3 ms 3780 KB