2
I’m trying to solve the 1805 URI issue:
A natural number is a non-negative integer (0, 1, 2, 3, 4, 5,...). Your task in this problem is to calculate the sum of the natural numbers that are present in a given range [To, B] inclusive.
For example, the sum of the natural numbers in the range [2, 5] is 14 = (2+3+4+5).
Entree
Each test case contains two integers To and B (1 To ≤ B 109), representing the lower and the upper limit respectively.
Exit
For each test case, the output consists of a line containing the sum of the natural numbers of the range.
But it’s always a mistake:
I don’t know what’s wrong with the results being equal to the question.
The code is this:
#include <stdio.h>
int main(int argc, char** argv)
{
long long int n1,n2,i,j=0;
scanf("%lld %lld",&n1,&n2);
for(i=n1;i<=n2;i++)
{
j+=i;
}
printf("%lld\n",j);
return 0;
}
https://pt.meta.stackoverflow.com/a/5485/28595
– user28595
Problem statement: https://www.urionlinejudge.com.br/judge/problems/view/1805
– Victor Stafusa
Since you are a novice user and the code is simple, I broke the branch and posted the code as text in the question for you. However, avoid posting code as image.
– Victor Stafusa
@vnbrs I understand you put that it is timeout error in the title, but I think the information that this is a timeout error is part of the answer, even more considering that the author of the question emphasizes "that the results are equal that the question", but nothing had talked about the weather.
– Victor Stafusa
all right, with time I’ll learn over time, thanks for the tips
– diogo.alves