AKB Forums

Go Back   AKB Forums > Technical sections > Algorithms
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Algorithms The source of algorithms for your project

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jul 14, 2002, 23:07   #1
Авик
 
CyberJoe's Avatar
 
Join Date: Jul 2002
Location: Yerevan
Posts: 1,347
Rep Power: 7
Reputation: 19
Send a message via ICQ to CyberJoe
Question Kto pomoget?

Narod kto znaet zadachu o 8 korolev v shaxmatax?
------------------
dlja tex kto ne znaet
Nado rasspologit 8 Koroliv na doske shaxmatnoj tak chtobi ni odna druguju ne bila
------------------
Esli kto moget podskazat algoritm pogaluista pomogite.
A esli u kogo on est napisannij na C++ to prishlite
Zaranie spasibo
__________________
вот собственно все, что я хотел сказать.
CyberJoe is offline   Reply With Quote Quote selected
Old Jul 15, 2002, 01:10   #2
Младенец
 
Join Date: Jul 2002
Location: Hell .. (the Netherlands)
Posts: 2
Rep Power: 0
Reputation: 10
Smile

ah.. ja ete znaju

palaji tak
E1,A2,H3,f4,C5,G6,B7,D8
__________________
hu...???, oh lol i got it!!!
MuZe is offline   Reply With Quote Quote selected
Old Jul 15, 2002, 02:43   #3
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,176
Rep Power: 7
Reputation: 41
Post

посмотри в книге вирта 'алгоритмы+структуры данных=программы', там на паскале, но думаю сойдет. а еще я ее на прологе писал, жаль, не сохранилась а то бы попугал
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old Jul 15, 2002, 11:25   #4
Студент
 
Join Date: Jun 2002
Location: Yerevan
Posts: 258
Rep Power: 7
Reputation: 10
Post

Quote:
Originally posted by MuZe:
ah.. ja ete znaju

palaji tak
E1,A2,H3,f4,C5,G6,B7,D8
A posle etogo mogesh' ciklicheski menyat' poloski doski both vertically and horizontally i poluchish' vse vozmognye varianty

A algorithm ochen' prostoj, prosto raspolagaesh' drug za drugom i obychno na 8-om shage mesta ne budet, pojdesh' nazad do xoda kogda u tebya byl vybor, vyberesh' chto-nibud' drugoe i tak dalee. Drugimi slovami - brute force
__________________
http://www.d-brane.com
Eddi is offline   Reply With Quote Quote selected
Old Jul 21, 2002, 01:31   #5
Студент
 
Join Date: May 2002
Location: Armenia
Posts: 276
Rep Power: 7
Reputation: 10
Post

BAYC ET XNDIRI MEJ KAROL CHI KARALEVA A
__________________
http://freenet.am/~getpaid
petar is offline   Reply With Quote Quote selected
Old Jul 22, 2002, 04:35   #6
Дошкольник
 
BlackMoon's Avatar
 
Join Date: May 2002
Location: The Dark Side of The Moon
Posts: 102
Rep Power: 7
Reputation: 10
Post

postav pervuu korolevu v verkhnem levom uglu
sleduushuu postav tochno tak kak esli bi ti
sigral konem v pravo i t.d. tak ti postavish 4
korolevi

potom 5-uu postvishish ot verkhnei levoi opiat
po zakonu khoda konia no uje vnis, i takje ostalnie
4 korolevi

naskolko ia snau eto edinstvenni algorithm
__________________
BM
BlackMoon is offline   Reply With Quote Quote selected
Old Jul 22, 2002, 08:19   #7
Студент
 
Join Date: Jun 2002
Location: Yerevan
Posts: 258
Rep Power: 7
Reputation: 10
Post

2 BlackMoon.

Eto skoree ne algoritm, a odno chastnoe reshenie (dlya sluchaya 8x8). Kotoroe vyshe uge bylo ukazano by MuZe. (i esli razlichno to kak ya uge opyat' taki skazal ciklicheskoj perestanovkoj vsex stolbcov i strok mogno poluchit' vse resheniya iz odnogo dannogo)
__________________
http://www.d-brane.com
Eddi is offline   Reply With Quote Quote selected
Old Jul 24, 2002, 23:40   #8
Авик
 
CyberJoe's Avatar
 
Join Date: Jul 2002
Location: Yerevan
Posts: 1,347
Rep Power: 7
Reputation: 19
Send a message via ICQ to CyberJoe
Post

Quote:
Originally posted by Eddi:
Ja uznal eta zadacha imeet 92 reshenija!!!
__________________
вот собственно все, что я хотел сказать.
CyberJoe is offline   Reply With Quote Quote selected
Old Jul 25, 2002, 01:23   #9
Студент
 
Join Date: Jun 2002
Location: Yerevan
Posts: 258
Rep Power: 7
Reputation: 10
Post

http://users.net1plus.com/brianl/8queens.htm - this has a java program using recursive algorithm.

I was wrong before stating that you'll get all the solutions from one. There are 12 different solutions (other 80 come from rotations and reflections).

http://mathworld.wolfram.com/QueensProblem.html - also this link gives you the formula to calculate the number of placings for nxn board and k queens.

Have fun
__________________
http://www.d-brane.com
Eddi is offline   Reply With Quote Quote selected
Old Jul 31, 2002, 13:54   #10
Младенец
 
Artsrun Ohanyan's Avatar
 
Join Date: Jan 2002
Location: Nor Hajen
Posts: 12
Rep Power: 0
Reputation: 10
Send a message via ICQ to Artsrun Ohanyan
Post

Nerkayatcnum em xndri lutsman im tsragir@, vor@ inchpes tesnum eq bavakanin kar& e yev ashxatum e shat arag...
Arajarkeq dzer@...

Code:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void main()
{
	vector< unsigned int > Pattern( 8 );
	for ( unsigned int i = 0; i <= 7; i++ ) 
		Pattern[ i ] = i + 1;

	unsigned int uiCount = 0;
	vector< unsigned int >::iterator start = Pattern.begin(), end = Pattern.end();
	while ( next_permutation( start, end ) )
	{
		bool bFound = true;
		for ( unsigned int i = 0; i <= 7 && bFound; i++ )
			for ( unsigned int j = i + 1; j <= 7 && bFound; j++ )
				bFound = ( abs( Pattern[ i ] - Pattern[ j ] ) != abs( i - j ) );
		if ( bFound )
		{
			uiCount++;
			ostream_iterator< unsigned int > outIt( cout, &quot; &quot; );
			copy( start, end, outIt );
			cout << endl;
		}
	}
	cout << endl << uiCount << &quot; solutions.&quot; << endl;
}
__________________
Best of luck!
Artsrun Ohanyan is offline   Reply With Quote Quote selected
Old Jul 31, 2002, 23:53   #11
Авик
 
CyberJoe's Avatar
 
Join Date: Jul 2002
Location: Yerevan
Posts: 1,347
Rep Power: 7
Reputation: 19
Send a message via ICQ to CyberJoe
Cool

Quote:
Spasibo!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
__________________
вот собственно все, что я хотел сказать.
CyberJoe is offline   Reply With Quote Quote selected
Old Aug 1, 2002, 19:10   #12
Школьник
 
Join Date: May 2002
Location: Yerevan
Posts: 202
Rep Power: 7
Reputation: 10
Send a message via ICQ to Amph
Post

Плохой алгоритм.... Идёт тупой перебор, а это не есть хорошо... Вот так вот.

В том же Дейтеле описан неплохой алгоритм, который достаточно легко реализовать, попробуй.

А вообще это задача на рекурсию с возвратом.
__________________
This game has no name,
It will never be the same....
Amph is offline   Reply With Quote Quote selected
Old Aug 27, 2002, 06:02   #13
Младенец
 
Join Date: Aug 2002
Location: Yerevan
Posts: 14
Rep Power: 0
Reputation: 10
Post

Рекурсивно решать или нет, все равно в основе решения этой задачи перебор. А рекурсия получается естественно, так-как посик идет по дереву кандидатов, так что каждая из его вершин приходится один раз. Это позволяет если найдено и должным образом зафиксировано одно решение, просто перейту к следующему кандидату, предлагаемому процессом полного перебора как в программе выше. Общая схема приблизительно такая.

void try(int i)
{
for ( int k = 0 to SQUARE_COUNT )
{
выбор к-го кандидата;
если подходит, записываем;
if ( i < SQUARE_COUNT )
try i+1);
}
}

Приблизительно так!
Вообще посмотрите в прекрасной статье Вирта "Program Development by Stepwise Refinement", классическая статья в программировании.
Удачи.
Joe Dering is offline   Reply With Quote Quote selected
Old Aug 27, 2002, 07:46   #14
ЙЦУКЕН
 
Join Date: Jul 2002
Location: 0x68,0x69,0x72, 0x69,0x6e,0x67, 0x20,0x6e,0x6f, 0x77
Posts: 3,113
Rep Power: 7
Reputation: 10
Send a message via ICQ to nm
Post

посик по дереву кандидатов ходит ? )
а кандидаты не жалуются ????

а так в принципе алгоритм именно такой )))

могу предложить другую более интерестную модификацию. Написать параллельный алгоритм для ее решения, который решает ее за (наи)меньшее количество времени
nm is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:59.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link