[Logo] Mendo Judge Discussion Board - Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
Instrukcii  XML
Forum Index » Други задачи
Author Message
nikola3103


[Avatar]

Joined: 25/12/2009 16:09:56
Messages: 184
Offline

Task :: Instrukcije
Little Marica started elementary school this year. Soon she will have her first exams, including the math exam. She is taking it seriously and thinks she is ready. Her older brother is helping her by giving her problems to solve.

In one of his problems he writes down a sequence of numbers consisting in order of one number 1,two numbers 2, three numbers 3 etc. Now he tells Marica two integers A and B; her task is to find the sum of integers with indices between A and B, inclusive. For example, if A is 1 and B is 3, then the answer is the sum of the first three elements, which is 1+2+2=5.

Write a program that finds the sum so that Marica's brother can verify her result.

INPUT:

The first and only line contains the positive integers A and B, 1 ≤ A ≤ B ≤ 1000.

OUTPUT:

Output the sum on a single line.


Input:
1 3

Output:
5


Input:
50 50

Output:
10


Input:
3 7

Output:
15


so se bara vo zadacata? :S ako ja sfakam ubavo test primerite im se gresni na prviot treba da bide (1+2+2+3+3+3) vtoriot (50+50+....{50pati}...+50) i tretiot (3+3+3+4+4+4+4+5+5+5+5+5+6+6+6+6+6+6+7+7+7+7+7+7+7), no ni edno resenie ne e taka :S
hristijan



Joined: 24/01/2010 09:42:46
Messages: 49
Offline

Не ја сфакаш добро. Имаш низа 1,2,2,3,3,3,4,4,4,4... и ти се бара збирот на елементите од индех i до индех ј. (А не збирот на сите броеви во низата што се помеѓу a и b) Значи во првиот тест случај од индех 1 до индех 3, тоа ти е 1+2+2, а во вториот тест случај имаш 50 50, значи почнуваш со 50 индех и завршуваш со него (само тој елемент го собираш).

This message was edited 1 time. Last update was at 24/03/2011 22:26:47

nikola3103


[Avatar]

Joined: 25/12/2009 16:09:56
Messages: 184
Offline

пак не сфатив , ако поцнувас со 50 и го собирас само него логицно е да е ресението 50, или ако поцнуас со 1 и одис до 3 тогас имаме 6 елеманти 1,2,2,3,3,3.... :S
bedzo



Joined: 18/01/2011 02:05:03
Messages: 234
Offline

Ако ти е инпутот 50 50 мислам дека оутпут треба да извадиш 50*50.

Инаку прати како можеш да го направиш.(reshenieto)

int a,b;
long long c=0;
cin>>a>>b;
for(int i=a;i<b;i++);
{
c+=i*i;
}
cout<<c;

This message was edited 1 time. Last update was at 26/03/2011 00:02:33

jovank



Joined: 01/01/2010 16:17:42
Messages: 127
Offline

50-тиот број во низата е 10: 1 2 2 3 3 3 4 4 4 4 ... 10. Затоа, кога ќе ги собереш броевите со индекси од 50 до 50, ти уствари го собираш само бројот 10, и добиваш резултат 10... во инпутот 50 тие е индексот на бројот од кој треба да поченш, што не значи дека 50-тиот број во низата е 50 (напротив, 50-тиот број во низата е 10)... пробав на 2 начина да ти објаснам, се надевам дека ќе ти стане појасно
[MSN]
nikola3103


[Avatar]

Joined: 25/12/2009 16:09:56
Messages: 184
Offline

aaaaa jaaasno teeenkju XD
hristijan



Joined: 24/01/2010 09:42:46
Messages: 49
Offline

Браво Јован, подобро од мене објаснуваш
 
Forum Index » Други задачи
Go to:   
Powered by JForum 2.1.8 © JForum Team