結果

問題 No.176 2種類の切手
ユーザー itezpaceitezpace
提出日時 2016-08-15 11:04:51
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,337 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 63,292 KB
実行使用メモリ 817,612 KB
最終ジャッジ日時 2024-04-25 07:21:32
合計ジャッジ時間 3,962 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int a,b,t;
  cin>>a>>b>>t;
  if(t%a==0 || t%b==0){
    cout<<t<<endl;
    return 0;
  }
  if(a>t && b>t){
    cout<<min(a,b)<<endl;
    return 0;
  } else if(a<=t && b<=t){
  int c,d;
  c=t/a+1;
  d=t/b+1;
  vector<int> va,vb;
  for(int i=1; i<=c; ++i){
    int e;
    e=(a*i)%t;
    va.push_back(e);
  }
  for(int i=1; i<=d; ++i){
    int f;
    f=(b*i)%t;
    vb.push_back(f);
  }
  int m;
  if(va[va.size()-1]<=vb[vb.size()-1]){
    m=va[va.size()-1];
  } else {
    m=vb[vb.size()-1];
  }
  for(int i=0; i<va.size()-1; ++i){
    for(int j=0; j<vb.size()-1; ++j){
      int g;
      g=va[i]+vb[j];
      if(g>=t){
        g-=t;
        if(g<m){
          m=g;
        }
      }
    }
  }
  int x;
  x=t+m;
  cout<<x<<endl;
  return 0;
} else if(a>t || b>t){
  int c,d,h;
  if(a>t){
    h=b;
    c=t/b+1;
    d=a;
  } else if(b>t){
    h=a;
    c=t/a+1;
    d=b;
  }
  vector<int> va;
  for(int i=1; i<=c; ++i){
    int e;
    e=(h*i)%t;
    va.push_back(e);
  }
  int m,pa;
  if(va[va.size()-1]<=d-t){
    m=va[va.size()-1];
  } else {
    m=d-t;
  }
  for(int i=0; i<va.size()-1; ++i){
    int g;
    g=va[i]+d-t;
    if(g>=t){
      g-=t;
      if(g<m){
        m=g;
      }
    }
  }
  int x;
  x=t+m;
  cout<<x<<endl;
  return 0;
  }
}
0