結果

問題 No.1446 ハンバーグと納豆ごはん
ユーザー heaveneleven521
提出日時 2021-03-31 15:18:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 427 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 167,408 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 23:35:36
合計ジャッジ時間 3,147 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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;
      }
  }
 }
 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;
      }
  }
 }
 cout << ans << endl;
}
0