Submission #12118636


Source Code Expand

Copy
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int n, k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=k; i<=n+1; i++){
		ll s=(ll)n*(n+1)/2-(n-i)*(n-i+1)/2-i*(i-1)/2+1;
		(ans+=s)%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Submission Info

Submission Time
Task D - Sum of Large Numbers
User chocorusk
Language C++ (GCC 9.2.1)
Score 400
Code Size 778 Byte
Status AC
Exec Time 5 ms
Memory 3636 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 3 ms 3520 KB
hand_02 AC 2 ms 3444 KB
max_01 AC 3 ms 3524 KB
max_02 AC 5 ms 3588 KB
random_01 AC 3 ms 3552 KB
random_02 AC 2 ms 3408 KB
random_03 AC 2 ms 3432 KB
random_04 AC 2 ms 3636 KB
random_05 AC 2 ms 3564 KB
random_06 AC 2 ms 3552 KB
random_07 AC 3 ms 3632 KB
random_08 AC 3 ms 3588 KB
random_09 AC 3 ms 3444 KB
random_10 AC 2 ms 3524 KB
random_11 AC 2 ms 3552 KB
random_12 AC 1 ms 3588 KB
sample_01 AC 2 ms 3636 KB
sample_02 AC 3 ms 3432 KB
sample_03 AC 3 ms 3552 KB