結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2021-01-28 20:39:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 418 bytes |
コンパイル時間 | 1,691 ms |
コンパイル使用メモリ | 193,080 KB |
最終ジャッジ日時 | 2025-01-18 08:35:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int cnt[20005]; int main(){ int a, b; cin >> a >> b; if(gcd(a,b)>1){ cout << -1 << endl; return 0; } int m = a*b-a-b; for(int i = 0; i <= 100; i++){ for(int j = 0; j <= 100; j++){ cnt[a*i+b*j]++; } } int ans = 0; for(int i = 1; i <= m; i++){ if(cnt[i]==0) ans++; } cout << ans << endl; return 0; }