結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー heaveneleven521
提出日時 2021-03-31 15:22:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 1,606 ms
コンパイル使用メモリ 166,240 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 23:47:54
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 23 WA * 10
権限があれば一括ダウンロードができます

ソースコード

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