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)