結果

問題 No.453 製薬会社
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2015-10-11 23:06:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,705 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 86,508 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 12:20:34
合計ジャッジ時間 1,439 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))

#define MOD 1000000007

// シンプレックス法

double dd[3][5];

int main() {
    int c,d;
    cin>>c>>d;
    clr(dd,0);
    dd[0][0] = -1000;
    dd[0][1] = -2000;
    dd[1][0] = 21;
    dd[1][1] = 8;
    dd[1][2] = 1;
    dd[1][4] = 28*c;
    dd[2][0] = 7;
    dd[2][1] = 20;
    dd[2][3] = 1;
    dd[2][4] = 28*d;
    while(1){
      int index1 = 0;
      int index2 = 0;
      double mn1 = 100000000;
      rep(i,0,4){
        if(dd[0][i]<mn1){
          index1 = i;
          mn1 = dd[0][i];
        }
      }
      if(mn1>=0)break;
      double mn2 = 100000000;
      rep(i,1,3){
        if(dd[i][4]/dd[i][index1]<mn2){
          index2 = i;
          mn2 = dd[i][4]/dd[i][index1];
        }
      }
      double a = dd[index2][index1];
      rep(i,0,5){
        dd[index2][i]/=a;
      }
      rep(i,0,3){
        if(i==index2)continue;
        double b = dd[i][index1];
        rep(j,0,5){
          if(j == index1){
            dd[i][j]=0;
          }
          else{
            dd[i][j] -= dd[index2][j]*b;
          }
        }
      }
    }
    printf("%10.10f\n",dd[0][4]);
    return 0;
}
0