标签:value std rom base frame btn ret toggle hose
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 400 points
ps:我发现一个很有趣的问题,long long和int 一起使用时,数据过大可能会出现错误,比如下面。所以最好还是统一用long long。
We have N+1 integers: 10^100 , 10^100+1, ..., 10^100+N .
We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (109+7) .
Input is given from Standard Input in the following format:
NK
Print the number of possible values of the sum, modulo (10^9+7) .
3 2
10
The sum can take 1010 values, as follows:
200000 200001
1
We must choose all of the integers, so the sum can take just 1 value.
141421 35623
220280457
#include <bits/stdc++.h> using namespace std; const int mod=1e9+7; int main(){ long long n,k;//若使用int n,k,答案错误 long long sum=0; cin>>n>>k; while(k<=n+1){ sum+=(2*n-k+1)*k/2-k*(k-1)/2+1; k++; } sum%=mod; cout<<sum<<endl; return 0; }
标签:value std rom base frame btn ret toggle hose
原文地址:https://www.cnblogs.com/asunayi/p/12772135.html