結果

問題 No.27 板の準備
ユーザー itezpaceitezpace
提出日時 2016-08-31 08:14:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,119 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 65,692 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 21:29:24
合計ジャッジ時間 1,569 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
int main(){
  int v0,v1,v2,v3;
  cin>>v0>>v1>>v2>>v3;
  vector<int> v;
  v.push_back(v0);
  v.push_back(v1);
  v.push_back(v2);
  v.push_back(v3);
  sort(v.begin(),v.end());
  int a=v[0];
  int b=v[1];
  int c=v[2];
  int d=v[3];
  int x=INT_MAX;
  for(int i=0; i<v.size(); ++i){
    for(int j=0; j<v.size(); ++j){
      if(i!=j){
        int e=v[i]%v[j];
        if(e==0){
          int p=v[i]/v[j]-1;
          if(p<x){
            x=p;
          }
        }
      }
    }
  }
  int y=INT_MAX;
  for(int i=0; i<=d/a; ++i){
    for(int j=0; j<=d/b; ++j){
      for(int k=0; k<=d/c; ++k){
        int o=a*i+b*j+c*k;
        if(i+j+k>1){
          for(int l=0; l<v.size(); ++l){
            int e=v[l]%o;
            if(e==0){
              int p=i+j+k+v[l]/o-3;
              if(i==0) p+=1;
              if(j==0) p+=1;
              if(k==0) p+=1;
              if(p<y){
                y=p;
              }
            }
          }
        }
      }
    }
  }
  int z=min(x,y);
  z+=4;
  cout<<z<<endl;
  return 0;
}
0