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

用了一個辅助程序验证了那个结论

Posted by KatrineYang at 2016-08-08 09:36:53 on Problem 1134 and last updated at 2016-08-08 09:37:26
辅助程序:
#include <iostream>
#include <cstdlib>
using namespace std;

int state[28];

int per[3][5][5] = {{{4,9,14,0,0},{2,7,12,17,0},{1,5,10,15,19},{3,8,13,18,0},{6,11,16,0,0}},
		{{14,17,19,0,0},{9,12,15,18,0},{4,7,10,13,16},{2,5,8,11,0},{1,3,6,0,0}},
		{{1,2,4,0,0},{3,5,7,9,0},{6,8,10,12,14},{11,13,15,17,0},{16,18,19,0,0}}};

int patt[9][5] = {{0,1,2,1,0},{0,1,0,1,2},{2,0,1,0,1},{2,2,0,1,0},
					{0,1,0,2,2},{0,1,0,2,1},{1,2,0,1,0},{0,1,2,0,1},{0,0,1,2,2}};

int weight[3] = {1,10,100};

void init(){
	for(int i = 1; i <= 19; i++) state[i] = 0;
}

void set(int *pat, int dir){
	for(int pIdx = 0; pIdx < 5; pIdx++){
		for(int j = 0; j < 5; j++){
			state[per[dir][pIdx][j]] += pat[pIdx] * weight[dir];
		}
	}
}

bool check(){
	int iii[248] = {0};
	for(int i = 1; i <= 19; i++){
		if(iii[state[i]] > 0){
			return false;
		}
		iii[state[i]] ++;
	}
	return true;
}

int main() {
	for(int i = 0; i < 9; i++){
		for(int j = i; j < 9; j++){
			for(int k = j; k < 9; k++){
				init();
				int pats[3];
				pats[0] = i, pats[1] = j, pats[2] = k;
				for(int fx = 0; fx < 3; fx++){
					set(patt[pats[fx]], fx);
				}
				//cout << i << j << k << endl;
				//for(int ii = 1; ii <= 19; ii++){cout << state[ii] << " ";} cout << endl;
				if(check()){
					cout << i << j << k << endl;
				}
			}
		}
	}
	return 0;
}
输出: 0 7 8


代妈:
#include <iostream>
using namespace std;

int mx(int a, int b){ return (a>b) ? a : b; }
int mn(int a, int b){ return (a<b) ? a : b; }

int main() {
	int cases;
	cin >> cases;
	for(int ii = 0; ii < cases; ii++){
		cout << "Test #" << ii+1 << endl;
		int dlw[3], qqw[3];
		for(int i = 0; i < 3; i++){
			int a1, a2, a3;
			cin >> a1 >> a2 >> a3;
			int MX = mx(a1, mx(a2,a3)), MN = mn(a1, mn(a2, a3));
			dlw[i] = 6*(a1+a2+a3)+2*MX-MN;
			qqw[i] = 7*(a1+a2+a3)-2*MN;
		}
		cout << mx(dlw[0]+qqw[1]+qqw[2], mx(qqw[0]+dlw[1]+qqw[2], qqw[0]+qqw[1]+dlw[2])) << endl << endl;
 	}
	return 0;
}


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