結果

問題 No.158 奇妙なお使い
ユーザー itezpaceitezpace
提出日時 2016-08-18 08:57:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,032 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 55,132 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-04-25 08:44:17
合計ジャッジ時間 7,231 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int a1,a2,a3,b1,b2,b3,c1,c2,c3,db,dc;
int x;

int calc1(int e1,int e2,int e3,int y){
  int y2;
  int xe1,xe2,xe3;
  xe1=e1;
  xe2=e2;
  xe3=e3;
  for(int i=e1; i>=0; --i){
    for(int j=e2; j>=0; --j){
      for(int k=e3; k>=0; --k){
        if(i*1000+j*100+k==db){
          xe1-=i;
          xe2-=j;
          xe3-=k;
          xe1+=b1;
          xe2+=b2;
          xe3+=b3;
          y2=y;
          y2++;
          if(y2>x) x=y2;
          calc1(xe1,xe2,xe3,y2);
        }
      }
    }
  }
  int xg1,xg2,xg3;
  xg1=xe1;
  xg2=xe2;
  xg3=xe3;
  for(int i=xe1; i>=0; --i){
    for(int j=xe2; j>=0; --j){
      for(int k=xe3; k>=0; --k){
        if(i*1000+j*100+k==dc){
          xg1-=i;
          xg2-=j;
          xg3-=k;
          xg1+=c1;
          xg2+=c2;
          xg3+=c3;
          y2=y;
          y2++;
          if(y2>x) x=y2;
          calc1(xg1,xg2,xg3,y2);
        }
      }
    }
  }
  return 0;
}

int calc2(int e1,int e2,int e3,int y){
  int y2;
  int xe1,xe2,xe3;
  xe1=e1;
  xe2=e2;
  xe3=e3;
  for(int i=e1; i>=0; --i){
    for(int j=e2; j>=0; --j){
      for(int k=e3; k>=0; --k){
        if(i*1000+j*100+k==dc){
          xe1-=i;
          xe2-=j;
          xe3-=k;
          xe1+=c1;
          xe2+=c2;
          xe3+=c3;
          y2=y;
          y2++;
          if(y2>x) x=y2;
          calc2(xe1,xe2,xe3,y2);
        }
      }
    }
  }
  int xg1,xg2,xg3;
  xg1=xe1;
  xg2=xe2;
  xg3=xe3;
  for(int i=xe1; i>=0; --i){
    for(int j=xe2; j>=0; --j){
      for(int k=xe3; k>=0; --k){
        if(i*1000+j*100+k==db){
          xg1-=i;
          xg2-=j;
          xg3-=k;
          xg1+=b1;
          xg2+=b2;
          xg3+=b3;
          y2=y;
          y2++;
          if(y2>x) x=y2;
          calc2(xg1,xg2,xg3,y2);
        }
      }
    }
  }
  return 0;
}

int main(){
  cin>>a1>>a2>>a3;
  cin>>db;
  cin>>b1>>b2>>b3;
  cin>>dc;
  cin>>c1>>c2>>c3;
  x=0;
  if(db<=dc){
    calc1(a1,a2,a3,0);
  } else {
    calc2(a1,a2,a3,0);
  }
  cout<<x<<endl;
  return 0;
}
0