poj2924---高斯求和
#include <stdio.h> #include <stdlib.h> int main() { int n,tim=0; long long ans,a,b; scanf("%d",&n); while(n--) { scanf("%lld %lld",&a,&b); ans = (a+b)*(b-a+1)/2; printf("Scenario #%d:\n",++tim); printf("%lld\n\n",ans); } }
long long 的范围:9223372036854775807~-9223372036854775808 亿万亿