結果
問題 | No.982 Add |
ユーザー |
|
提出日時 | 2020-02-11 23:44:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 466 bytes |
コンパイル時間 | 2,443 ms |
コンパイル使用メモリ | 194,256 KB |
最終ジャッジ日時 | 2025-01-08 23:44:06 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> int main(){ int A, B; std::cin >> A >> B; if(std::gcd(A, B) != 1){ std::cout << -1 << std::endl; }else{ int N = std::lcm(A, B); std::vector<int> check(N+1, 1); check[0] = 0; for(int x = 0; x <= B; ++x){ for(int y = 0; y <= A; ++y){ if(A*x+B*y <= N) check[A*x+B*y] = 0; } } int ans = std::count(check.begin(), check.end(), 1); std::cout << ans << std::endl; } return 0; }