結果

問題 No.982 Add
ユーザー cureskolcureskol
提出日時 2020-02-11 16:13:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,659 ms / 2,000 ms
コード長 439 bytes
コンパイル時間 1,716 ms
コンパイル使用メモリ 172,516 KB
実行使用メモリ 135,180 KB
最終ジャッジ日時 2024-04-08 15:34:11
合計ジャッジ時間 30,782 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,063 ms
135,180 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 1,385 ms
135,180 KB
testcase_03 AC 1,570 ms
135,180 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 1,576 ms
135,180 KB
testcase_06 AC 1,608 ms
135,180 KB
testcase_07 AC 1,572 ms
135,180 KB
testcase_08 AC 1,393 ms
135,180 KB
testcase_09 AC 1,652 ms
135,180 KB
testcase_10 AC 1,659 ms
135,180 KB
testcase_11 AC 1,556 ms
135,180 KB
testcase_12 AC 1,282 ms
135,180 KB
testcase_13 AC 1,398 ms
135,180 KB
testcase_14 AC 1,443 ms
135,180 KB
testcase_15 AC 1,448 ms
135,180 KB
testcase_16 AC 1,634 ms
135,180 KB
testcase_17 AC 1,614 ms
135,180 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 1 ms
6,548 KB
testcase_24 AC 1,654 ms
135,180 KB
testcase_25 AC 1,637 ms
135,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int a,b;cin>>a>>b;
  if(__gcd(a,b)>1)fin(-1);
  vector<int> v;
  if(a>b)swap(a,b);
  for(int i=0;i<5000;i++)for(int j=0;j<5000;j++)v.push_back(a*i+b*j);
  sort(v.begin(),v.end());
  unique(v.begin(),v.end());
  int ans=0;
  for(int i=0;i<100000;i++)
    if(v[i]<=a*b)
      ans+=v[i+1]-v[i]-1;
  fin(ans);
}
0