Mata-i grasa _|_
RST  

Go Back   RST > >> 1337 Zone << > Competitie [challenges]

Competitie [challenges] Challenge-uri aka Wargames! Enjoy resolving them!

Reply
Old 12-03-2009, 08:45 PM   #1 (permalink)
Registered Users
Cultul betivilor
 
Join Date: Feb 2008
Location: Romania
Posts: 1,111
Rep Power: 0
Hertz is an unknown quantity at this point
Hertz is offline

Default [Programare]Numere hexagonale


hotel regim hotelier
hotel yahoo domain
Un numar hexagonal se compune folosind urmatoarea formula :

H(n) = n(2n-1)

Primele 5 numere hexagonale sunt :

1 6 15 28 45

Cate dintre primele 100.000.000 numere hexagonale se impart cu toate numerele intre 1 si 20?
__________________
  Reply With Quote
Sponsored Links
Re: [Programare]Numere hexagonale
Old 12-03-2009, 09:19 PM   #2 (permalink)
Moderator
Cultul betivilor
 
begood's Avatar
 
Join Date: Jun 2008
Posts: 2,634
Rep Power: 5
begood will become famous soon enough
Send a message via Yahoo to begood
begood is offline
Default

Code:
#include <fstream.h>
void main ()
	{
        long s=0,x;
	for(unsigned long i=232792559;i<=100000000;i++)
		{
		x=i*(2*i-1);
		if(x%2 && x%3 && x%5 && x%7 && x%11 && x%13 && x%17 && x%19)
			s++;
		}
	cout<<s;
	}
232792559>100000000 so 0.
cmmmc(1,2...20) = 232792559

//le e gresit, revin alta data cu un edit.
  Reply With Quote
Re: [Programare]Numere hexagonale
Old 12-03-2009, 10:40 PM   #3 (permalink)
Moderator
Cultul betivilor
 
loki's Avatar
 
Join Date: Feb 2008
Posts: 2,943
Rep Power: 5
loki will become famous soon enough
loki is offline
Default

cmmmc(1-20)=232,792,560

Code:
#include <iostream.h>
int main()
	{
        long s=0,x=0;
	for(unsigned long i=1;i<=100000000;i++)
		{
		x=i*(2*i-1);
		if(!(x%232792560))
			s++;
		}
	cout<<s;
	}
begood: ti-am ajustat programul.
codepad zice ca unu singur.
__________________
  Reply With Quote
Last edited by loki; 12-03-2009 at 10:47 PM.
Re: [Programare]Numere hexagonale
Old 12-20-2009, 10:59 PM   #4 (permalink)
tw8
Registered Users
Bautor de whiskey
 
Join Date: Jun 2006
Location: Drobeta Turnu Severin
Posts: 490
Rep Power: 5
tw8 se balangane pe drum
tw8 is offline
Default

Folosindu-ne de inversa functiei H(n), putem lua doar numerele divizibile cu 232792560 - adica cel mai mic multiplu comun al numerelor de la 1 la 20 - si sa verificam daca sunt hexagonale. Asta scuteste de o gramada de calcule inutile .
Rezultatul programului meu:

Code:
Numarul #1: H(1348848) = 3638780505360
Numarul #2: H(5925920) = 70233049766880
Numarul #3: H(7274768) = 105844491632880
Numarul #4: H(8751600) = 153180996368400
Numarul #5: H(9267440) = 171770879039760
Numarul #6: H(11099088) = 246379497764400
Numarul #7: H(11309760) = 255821331205440
Numarul #8: H(12093120) = 292487090575680
Numarul #9: H(14440608) = 417062304378720
Numarul #10: H(14651280) = 429319996625520
Numarul #11: H(17127968) = 586734558490080
Numarul #12: H(17338640) = 601256856760560
Numarul #13: H(18019040) = 649371587024160
Numarul #14: H(19686128) = 775087251578640
Numarul #15: H(20577200) = 846842299102800
Numarul #16: H(22511808) = 1013562976345920
Numarul #17: H(23192208) = 1075757000638320
Numarul #18: H(23402880) = 1095389561185920
Numarul #19: H(25750368) = 1326162878520480
Numarul #20: H(28437728) = 1617408719166240
Numarul #21: H(30430400) = 1852018457889600
Numarul #22: H(31779248) = 2019841175111760
Numarul #23: H(33256080) = 2211933680676720
Numarul #24: H(35603568) = 2535228073057680
Numarul #25: H(35814240) = 2565319537740960
Numarul #26: H(36494640) = 2663717460964560
Numarul #27: H(39182000) = 3070458208818000
Numarul #28: H(41740160) = 3484481871911040
Numarul #29: H(42523520) = 3616499463857280
Numarul #30: H(44355168) = 3934761812261280
Numarul #31: H(44565840) = 3972228145245360
Numarul #32: H(45081680) = 4064715698163120
Numarul #33: H(46913328) = 4401720641157840
Numarul #34: H(47696688) = 4549948044642000
Numarul #35: H(47907360) = 4590230236431840
Numarul #36: H(50254848) = 5051099444751360
Numarul #37: H(52942208) = 5605754722888320
Numarul #38: H(53833280) = 5796044017283520
Numarul #39: H(57657600) = 6648797617862400
Numarul #40: H(59006448) = 6963521752146960
Numarul #41: H(60999120) = 7441785220549680
Numarul #42: H(63686480) = 8111935405894320
Numarul #43: H(66244640) = 8776704591214560
Numarul #44: H(68859648) = 9483302176508160
Numarul #45: H(69070320) = 9541418140734480
Numarul #46: H(69750720) = 9730325811286080
Numarul #47: H(71417808) = 10201006527631920
Numarul #48: H(72308880) = 10457148181399920
Numarul #49: H(74996240) = 11248871953278960
Numarul #50: H(78337760) = 12273609205297440
Numarul #51: H(80169408) = 12854267877971520
Numarul #52: H(82162080) = 13501214697690720
Numarul #53: H(83510928) = 13948150107331440
Numarul #54: H(88834928) = 15783288776695440
Numarul #55: H(90913680) = 16530594331371120
Numarul #56: H(93471840) = 17473969652499360
Numarul #57: H(94255200) = 17768085359824800
Numarul #58: H(96813360) = 18745653252165840
Numarul #59: H(99500720) = 19800786461536080

In total, exista 59 numere!
__________________

Exista 10 feluri de oameni: cei care inteleg sistemul binar si cei care nu il inteleg.
  Reply With Quote
Reply

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump




Copywr0ng (c) 2009 Miercuri catre Joi - RST
All logos and trademarks in this site are property of their respective

Hosted by powerhost.ro