Re: find a number



CBFalconer:

s = 0; i = 0;
do {
s -= i;
s += a[i++];
} while (i <= 1001);

minor optim.:

s = 0; i = 1(0);
while (i<1002(1001)) s+=a[i++];
s-=500500; (or (1000+1)*1000/2 - Gauss ;P, but precalculated is better)

printf("duplicate is %d\n", s);


--
Sc0rpi0
I hated going to weddings.
All the grandmas would poke me saying "You're next".
They stopped that when I started doing it to them at funerals.
.



Relevant Pages

  • Re: action script we flashu
    ... I hated going to weddings. ... All the grandmas would poke me saying "You're next". ...
    (comp.programming)
  • Re: anyone still here?
    ... I hated going to weddings. ... All the grandmas would poke me saying "You're next". ...
    (comp.ai.games)
  • Re: anyone still here?
    ... I hated going to weddings. ... All the grandmas would poke me saying "You're next". ...
    (comp.ai.games)
  • Re: Jesus said
    ... Aaand FUT, aaand bye... ... I hated going to weddings. ... All the grandmas would poke me saying "You're next". ...
    (comp.programming)
  • Re: Randy apparently wanted me to post this to MTR
    ... Are you saying that somebody that has an argument that requires people to be ... lunatic I met on the Internet with a car jack. ... and people who be stupid tend to commit crimes. ... I like to poke and poke and poke at idiots ...
    (misc.transport.road)