Results 1 to 3 of 3

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Eclipse Plugin Developer aphex's Avatar
    Join Date: Mar:2003
    Location: Karlsruhe
    Posts: 546

    28 projecteuler.net

    ,
    . , , . ?!?

    , , .

    public 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);
    }
    }
    6.69171003E8

    !
    We are drowning in information, but starving for knowledge and time!

  2. #2
    Registered 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.

  3. #3
    Eclipse Plugin Developer aphex's Avatar
    Join Date: Mar:2003
    Location: Karlsruhe
    Posts: 546
    zstoev, . . , .. !
    We are drowning in information, but starving for knowledge and time!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |