[Zhengqing] [1820] LT's Plea for Help

Problem Description

Loading...

Problem Analysis

The pitfall is the data range
You can’t use int
Nothing else to worry about

cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#include<stdio.h>
int main() {
	int T;
	int i;
	long long sum,n;
	scanf("%d",&T);
	while(T--) {
		scanf("%lld",&n);
		sum=n*(n+1)/2;
		printf("%lld\n",sum);
	}
}

Problem link: [ZZULI][1820] LT’s Request for Help

This post is licensed under CC BY-NC-SA 4.0. If it helped, or if you have anything to say, the comment box below is open.
Page views —
Unique visitors —

Loading...