POJ 2924 Gauß in Elementary School(水~)
来源:互联网 发布:直播实时转播软件 编辑:程序博客网 时间:2024/05/17 01:10
Description
给出两个数s和e,输出s+…+e
Input
第一行为用例组数t,每组用例占一行包括两个整数s和e(-10^9<=s,e<=10^9)
Output
Sample Input
3
1 100
-11 10
-89173 938749341
Sample Output
Scenario #1:
5050
Scenario #2:
-11
Scenario #3:
440625159107385260
Solution
水题
Code
#include<stdio.h>typedef long long ll;int main(){ int n,res=1; ll s,e,ss,ee; scanf("%d",&n); while(n) { scanf("%lld%lld",&s,&e); ss=s>=0?s:-s; ee=e>=0?e:-e; if(s>0&&e>0) { ss=(ss-1)*ss/2; ee=(ee+1)*ee/2; } else if(s<=0&&e>=0) { ss=(ss+1)*ss/2; ee=(ee+1)*ee/2; } else if(s<0&&e<0) { ss=(ss+1)*ss/2; ee=(ee-1)*ee/2; } printf("Scenario #%d:\n",res); printf("%lld\n\n",ee-ss); res++; n--; } return 0;}
0 0
- POJ 2924 Gauß in Elementary School(水~)
- poj 2924 Gauß in Elementary School
- POJ 2924 Gauß in Elementary School(简单题)
- POJ 2924 Gauß in Elementary School 解题报告
- POJ 2924 Gauß in Elementary School G++
- TOJ 2346.Gauß in Elementary School
- POJ 2924 Gauß in Elementary School(我的水题之路——n到m的连和)
- fjnu 1943 Gau? in Elementary School
- POJ 1922:Ride to School 【水】
- Ride to School(POJ 1922)
- POJ 1922 Ride to School (贪心)
- POJ 1922 Ride to School(找规律题,数学)
- POJ 1922 Ride to School(找规律题,数学)
- POJ 1236 Network of School(强联通缩点)
- The Changes in Our School
- POJ 1922 Ride to School
- POJ 1922 Ride to School
- POJ 1922 Ride to School
- LinkedHashMap实现原理
- GRE写作必备句型
- 《Spring技术内幕》学习笔记10——Web环境中Spring的启动过程
- pow(double x,int n)
- c# 多线程详解
- POJ 2924 Gauß in Elementary School(水~)
- 数据库按条件迁移表的列的值
- 在opencv中,强分类器阈值是如何确定的?虚警率是怎么计算的?
- windows下用swig实现python调用C\C++的方法
- 最大公约数和最小公倍数的计算
- 2012年5月SAT香港真题解析
- 《Spring技术内幕》学习笔记11——JdbcTemplate封装Jdbc
- NSMutableString
- 【LintCode】Insert Intervals 插入区间