結果
問題 |
No.982 Add
|
ユーザー |
![]() |
提出日時 | 2025-07-18 00:16:09 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 596 bytes |
コンパイル時間 | 2,928 ms |
コンパイル使用メモリ | 280,868 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-18 00:16:14 |
合計ジャッジ時間 | 4,411 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int a, b; cin >> a >> b; if (gcd(a, b) != 1) { cout << -1 << '\n'; } else { set<int> s; rep(x, a * b) s.insert(x); for (int i = 0; i <= b; ++i) { for (int j = 0; j <= a; ++j) { s.erase(i * a + j * b); } } cout << s.size() << '\n'; } return 0; }