Heeju's Math Exam
Time limit1sMemory limit128 MB
Sum the terms from position A to B in the sequence where each integer k appears k times in a row.
- Level
Easy2 of 10
- Topics
- Simulation, Implementation
- Solved
- No attempts yet
Problem
An integer sequence is built by the following rule: 1 appears once, 2 appears twice, 3 appears three times, …, that is, the integer appears times in a row. So the sequence begins like this.
Given two integers and , compute and print the sum of all values from the -th term to the -th term of this sequence, inclusive.
Input
A single line contains two integers and separated by a space. ()
Output
Print, on one line, the sum of the terms from the -th to the -th.