AtCoder Beginner Contest 163----D - Sum of Large Numbers(思维)

你是我可爱的诱惑,温柔的牵绊,无法割舍的存在.你说青涩最搭初恋,我们有相遇的时间,在风暖月光的地点,海之角也不再遥远.你我之间,看不见的宣言,一直都在,重复过很多年.

 AtCoder Beginner Contest 163----D - Sum of Large Numbers(思维)

题解如下图: 

AtCoder Beginner Contest 163----D - Sum of Large Numbers(思维)

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <complex>
#include <iomanip>
#include <numeric>
#include<unordered_set>
#include <climits>//INT_100010n
#include <regex>
#include<deque>
//#include<bits/stdc++.h>
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926535898
#define wc 1e-18
typedef long long ll;
using namespace std;
priority_queue<int,vector<int>,less<int> > lp;
priority_queue<int,vector<int>,greater<int> >gp;
const ll mod=1e9+7;
int n,k;
ll jg=0;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=k; i<=n+1; i++)
        jg=(jg+(ll)i*(2*n-i+1)/2-(ll)i*(i-1)/2+1)%mod;
    cout<<jg<<endl;
    return 0;
}

 

上一篇:python工业互联网应用实战3—Django Admin列表


下一篇:Redis的几个核心机制底层原理