結果
問題 |
No.27 板の準備
|
ユーザー |
![]() |
提出日時 | 2015-06-25 03:39:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,727 bytes |
コンパイル時間 | 909 ms |
コンパイル使用メモリ | 90,512 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 17:32:02 |
合計ジャッジ時間 | 1,474 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 8 |
ソースコード
#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; }