Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
See this time, I confused ...
Sure enough, Java is to hit the table, can not AC, because Java input is a stream, it takes more time than C really much longer ....
Problem Description
You just need to calculate the sum of the formula:1^2+3^2+5^2+......+ n ^2.
Input
In each case, the there is an odd positive integer n.
Output
Print the sum. Make sure the sum would not exceed 2^31-1
Sample Input
3
Sample Output
10
A simple question, it is not translated.
Attach the C language code of AC:
#include <iostream>Const intmax=2345;//Calculate 2345 is just greater than 2^31-1, input output with scanf and printf can not cin and cout otherwise timeout__int64 Db[max];using namespace STD;intMain () {intN,m,i; db[1]=1;//Play Table method for(i=3; i<=max;i+=2) {db[i]=db[i-2]+i*i; } while(scanf("%d", &n)!=eof) {printf("%i64d\n", Db[n]); }return 0;}
Hdoj (HDU) 2139 Calculate The formula (water problem, another problem with JAVAAC)