結果

問題 No.982 Add
コンテスト
ユーザー cureskol
提出日時 2020-02-11 16:11:58
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 412 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,456 ms
コンパイル使用メモリ 187,072 KB
実行使用メモリ 134,748 KB
最終ジャッジ日時 2026-04-17 08:23:31
合計ジャッジ時間 24,656 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:17:9: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]', declared with attribute 'nodiscard' [-Wunused-result]
   17 |   unique(v.begin(),v.end());
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:875:5: note: declared here
  875 |     unique(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~

ソースコード

diff #
raw source code

#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<1000;i++)ans+=v[i+1]-v[i]-1;
  fin(ans);
}
0