結果

問題 No.982 Add
ユーザー 👑 CleyL
提出日時 2023-03-22 09:13:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 315 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 66,616 KB
最終ジャッジ日時 2025-02-11 16:10:00
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int gcd(int a,int b){
  if(a%b)return gcd(b,a%b);
  return b;
}
int main(){
  int a,b;cin>>a>>b;
  if(a>b)swap(a,b);
  if(gcd(a,b) != 1){
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  for(int i = 0; a > i; i++){
    ans += (b*i)/a;
  }
  cout << ans << endl;
}
0