結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2020-02-11 15:09:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 417 bytes |
コンパイル時間 | 616 ms |
コンパイル使用メモリ | 68,056 KB |
最終ジャッジ日時 | 2025-01-08 23:38:44 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> using namespace std; int gcd(int x, int y){ if(y>x) swap(x,y); if(y==0) return x; return gcd(x%y,y); } int c[20010]; int main(){ int i,j,a,b,ans = 0; cin >> a >> b; if(gcd(a,b)!=1){ cout << -1 << endl; return 0; } for(i=1;i<=a*b;i++){ c[i] = 1; } for(i=0;i<=b;i++){ for(j=0;j<=a;j++){ c[a*i + b*j] = 0; } } for(i=1;i<=a*b;i++){ ans += c[i]; } cout << ans << endl; }