Results 1 to 3 of 3
Thread: 28 projecteuler.net
Hybrid View
-
29th February 2008 02:08 #1
28 projecteuler.net
,
. , , . ?!?
, , .
6.69171003E8public class clockwiseMatrix {
public static void main(String args[]){
double[] party;
party = new double[2003];
int start=1;
int counter=0;
int pimp=0;
do{
party[counter]=start;
counter++;
pimp=pimp+2;
start=start+pimp;
} while (counter!=1001);
party[1001]=2;
party[1002]=4;
counter=1003;
int pim=6;
int startt=10;
do{
party[counter]=startt;
startt=startt+pim;
counter=counter+1;
party[counter]=startt;
counter=counter+1;
pim=pim+4;
startt=startt+pim;
}while(counter<2002);
double grr=0;
for(int i=0;i<=2001;i++){
Out.println(i+" : "+party[i]);
grr=grr+party[i];
}
Out.println(grr);
}
}
!
We are drowning in information, but starving for knowledge and time!
-
29th February 2008 16:13 #2Registered User
Join Date: Apr:2004
Location: EU
Posts: 141
669171001
+ 1 ()
() n 3, 5 ... 1001
, , .. :
a, a-b, a-2*b, a-3*b
:
a = n^2
b = n-1
Code:static void Main(string[] args) { int sum = 1; for (int i = 3; i <= 1001; i += 2) { int a = i * i; int b = i - 1; sum += a + (a - b) + (a - 2 * b) + (a - 3 * b); } Console.Write(sum); }Last edited by zstoev; 29th February 2008 at 16:35.
-
29th February 2008 18:48 #3
zstoev, . . , ..
!
We are drowning in information, but starving for knowledge and time!




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in