結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー heaveneleven521heaveneleven521
提出日時 2021-03-31 15:22:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 166,588 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-08 17:49:49
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long a,b,n,m;
 cin >> a >> b >> n >> m;
 int ans = 0;
 if(a>b){
 ans = b+(a-b)/n;
  if(ans>a-(a-b)/n){
      int s = a-(a-b)/n;
      while(ans>s){
          ans-=n;
          s+=n;
      }
      ans-=n;
  }
 }
 else{
 ans = a+(b-a)/m;
  if(ans>b-(b-a)/m){
      int t = b-(b-a)/m;
      while(ans>t){
          ans-=m;
          t+=m;
      }
      ans-=m;
  }
 }
 cout << ans << endl;
}
0