結果
| 問題 |
No.982 Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-11 18:28:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 542 bytes |
| コンパイル時間 | 1,581 ms |
| コンパイル使用メモリ | 166,224 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-16 00:21:12 |
| 合計ジャッジ時間 | 2,549 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool dp[10005];
int main(void){
int a, b;
cin >> a >> b;
if(__gcd(a, b) != 1){
cout << -1 << endl;
return 0;
}
int ans = 0;
int ub = a * b;
for(int i = 0; i <= b; ++i){
for(int j = 0; j <= a; ++j){
if(i == 0 && j == 0) continue;
int foo = a * i + b * j;
if(foo > ub) continue;
dp[foo] = true;
}
}
for(int i = 1; i <= ub; ++i) if(!dp[i]) ++ans;
cout << ans << endl;
}