Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么不对啊?(WA)

Posted by bj051105 at 2007-04-18 16:05:08 on Problem 1166
#include <iostream.h>
void main()
{
	int i,j,k,num,d[11],n[11],a[11];
	for(i = 1;i < 10;i++)
		cin >> n[i];
	num = 9;
	for(d[1] = 0;d[1] < 2;d[1]++)
		for(d[2] = 0;d[2] < 2;d[2]++)
			for(d[3] = 0;d[3] < 2;d[3]++)
				for(d[4] = 0;d[4] < 2;d[4]++)
					for(d[5] = 0;d[5] < 2;d[5]++)
						for(d[6] = 0;d[6] < 2;d[6]++)
							for(d[7] = 0;d[7] < 2;d[7]++)
								for(d[8] = 0;d[8] < 2;d[8]++)
									for(d[9] = 0;d[9] < 2;d[9]++)
										if(d[1]+d[2]+d[4] == (4-n[1])%4 && d[1]+d[2]+d[3]+d[5] == (4-n[2])%4 && d[2]+d[3]+d[6] == (4-n[3])%4 && d[1]+d[4]+d[5]+d[7] == (4-n[4])%4 && d[1]+d[3]+d[5]+d[7]+d[9] == (4-n[5])%4 && d[3]+d[5]+d[6]+d[9] == (4-n[6])%4 && d[4]+d[7]+d[8] == (4-n[7])%4 && d[5]+d[7]+d[8]+d[9] == (4-n[8])%4 && d[6]+d[8]+d[9] == (4-n[9])%4)
										{
											j = 0;
											for(i = 1;i < 10;i++)
												if(d[i] == 1)
													j = j + 1;
												else
													continue;
											if(j < num)
											{
												k = 0;
												num = j;
												for(i = 1;i < 10;i++)
													if(d[i] == 1)
													{
														a[k] = i;
														k = k + 1;
													}
													else
														continue;
											}
											else
												continue;
										}
	for(i = 0;i < num;i++)
		cout << a[i] << " ";
	cout << endl;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator