結果

問題 No.2781 A%B問題
ユーザー tanaka255
提出日時 2024-06-14 21:23:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 2,162 ms
コンパイル使用メモリ 192,052 KB
最終ジャッジ日時 2025-02-21 21:40:33
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template<typename T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void solve();
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int t = 1;
  //cin >> t;
  while (t--) {
    solve();
  }
}
int A,B;
void solve() {
  cin>>A>>B;
  for(int q=-1000;q<=1000;++q){
    int r=A-B*q;
    if(0<=r&&r<abs(B)){
      cout<<r<<endl;
      return;
    }
  }
}
0