1171: Sum Kind of Problem发表时间:2022-10-27 19:24 1171: Sum Kind of Problem时间限制: 1 Sec 内存限制: 128 MB 题目描述For this problem you will compute various running sums of values for positive integers. 输入The first line of input contains a single integer P, (1 ≤ P≤ 10000), which is the number of data sets 输出For each data set there is one line of output. The single output line consists of the data set number, 样例输入 Copy3 1 1 2 10 3 1001 样例输出 Copy1 1 1 2 2 55 100 110 3 501501 1002001 1003002 #include<bits/stdc++.h> using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int n,k; scanf("%d%d",&k,&n); long long ans1=1LL*n*(n+1)/2; long long ans2=1LL*n*n; long long ans3=1LL*n*(2+2*n)/2; printf("%d %lld %lld %lld\n",k,ans1,ans2,ans3); } return 0; }
上一篇1201: 墩墩的零花钱
下一篇1164: 首签是我的
文章分类:
算法例题
|