UVa 913

From Algorithmist
Jump to navigation Jump to search

913 - Joana and the Odd Numbers[edit]


The only problem here is to calculate the last number of the n-th line. Bruteforce won't do it


First you can calculate the number of numbers per line. That is

Now you know how many numbers you have in one line. To get the last number of the n-th line, you need to know how many numbers there were before that line + the number of numbers in that line. So you can simply sum that up

The last number of the n-th is then:

Now you can simply calculte the sum:


  • You need to use long long int to do the calculations