結果

問題 No.27 板の準備
ユーザー ty70ty70
提出日時 2015-06-25 03:39:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,727 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 90,168 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 00:36:45
合計ジャッジ時間 1,895 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,384 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<20

/*

	No.27 板の準備

	全探索、全探索?
*/
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	vector<int> V(4, 0 );
	rep (i, 4 ) cin >> V[i];
	vector<int> order(4, 0 );
	rep (i, 4 ) order[i] = i;
	int res = INF;
	do{
		vector<int> cand (3, 0 );
		rep (i, 3 ) cand[i] = V[order[i]];
		int to = V[order[3]];
		for (int x = 0; x <= to/cand[0]; x++ ){
			for (int y = 0; y <= to/cand[1]; y++ ){
				for (int z = 0; z <= to/cand[2]; z++ ){
					if (x*cand[0] + y*cand[1] + z*cand[2] == to ){
/*
						rep (i, 3 ){
							cerr << "cand: " << cand[i] << endl;
						} // end rep
						cerr << "to: " << to << endl;

						cerr << "x: " << x << " y: " << y << " z: " << z << endl;
*/
						res = min (res, x + y + z + 3 );
					} // end if
				} // end for
			} // end for
		} // end for
	}while (next_permutation (ALL (order ) ) );

	cout << res << endl;

	return 0;
}
0