Hdoj (HDU) 2520 I am a rookie, I am afraid of who (arithmetic progression)

Source: Internet
Author: User

Problem Description
LIN2144 is a small rookie, are clumsy birds have, lin2144 want a rookie first fly, he started from 0.
At the beginning of the flight speed of 1m/s, each one unit time lin2144 flight speed than the previous unit time flight speed 2m/s, Q N (0 < n < 10^5) unit time after lin2144 flew how far?

Input
Enter a T to indicate that there are several sets of data
Each set of data is entered with an n representing the time of the lin2144 flight.

Output
Output lin2144 flew how far, because the number is very large, so the 10000 modulo.

Sample Input
2
1
2

Sample Output
1
4

It is simple, you can use the series to sum, you can also play the table.
Pay attention to the 10000 modulo;

Import Java.util.Scanner; Public classmain{Static intDb[] =New int[100005]; Public Static void Main(string[] args)        {Dabiao (); Scanner sc =NewScanner (System.inch);intT =sc.nextint (); while(t-->0){intn =sc.nextint (); System. out. println (Db[n]); }    }Private Static void Dabiao() {db[1]=1;intsum=1; for(intI=2; i<=100000; i++) {sum= (sum+2)%10000; Db[i]= (db[i-1]+sum)%10000; }    }}

Hdoj (HDU) 2520 I am a rookie, I am afraid of who (arithmetic progression)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.