H Question Hdu 2520 I'm a rookie, I'm afraid of WHO

Source: Internet
Author: User

Title: http://acm.hdu.edu.cn/showproblem.php?pid=2520

I'm a rookie, I'm afraid of WHO

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 7698 Accepted Submission (s): 4505


Problem Descriptionlin2144 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 a T is expressed as having several sets of data
Each set of data is entered with an n representing the time of the lin2144 flight.

Output lin2144 How far is the flight, because the number is large, so the 10000 modulo.

Sample Input212

Sample Output14

Sourcehdu 2008-10 Programming Contest title to the main idea:, every one unit time flight speed than the previous unit time flight speed 2m/s, so with two arrays, one to record the distance, one to record the speed, so OK. See the code.
1#include <iostream>2#include <cstdio>3 4 using namespacestd;5 6 intnum1[100010],num2[100010];7 8 intMain ()9 {Tennum1[0]=1; Onenum2[0]=0; A      for(intI=1; i<100000; i++) -     { -Num2[i]= (num1[i-1]+num2[i-1])%10000; thenum1[i]=num1[i-1]+2; -     } -     intT; -scanf"%d",&t); +      while(t--) -     { +         intN; Ascanf"%d",&n); atprintf ("%d\n", Num2[n]); -  -     } -     return 0; -}

H Question Hdu 2520 I'm a rookie, I'm afraid of WHO

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.