Re: find a number
- From: Sc0rpi0 <sc0rpi0@xxxxxxxxxxxxxx>
- Date: Thu, 30 Mar 2006 15:25:07 +0200
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.
.
- References:
- find a number
- From: murali@pune
- Re: find a number
- From: Sc0rpi0
- Re: find a number
- From: Mark P
- Re: find a number
- From: Arthur J. O'Dwyer
- Re: find a number
- From: CBFalconer
- find a number
- Prev by Date: Re: String concatenation design
- Next by Date: Re: find a number
- Previous by thread: Re: find a number
- Next by thread: Re: find a number
- Index(es):
Relevant Pages
|