結果
問題 | No.982 Add |
ユーザー |
|
提出日時 | 2020-04-12 18:21:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 504 bytes |
コンパイル時間 | 418 ms |
コンパイル使用メモリ | 55,908 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 04:34:46 |
合計ジャッジ時間 | 1,409 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <iostream> using namespace std; int gcd(int x,int y){ return (y>0?gcd(y,x%y):x); } int main(){ int A,B; cin >> A >> B; if(gcd(A,B)==1){ bool found[2*100*100+1]={0}; for(int x=0;x<100;x++){ for(int y=0;y<100;y++){ found[A*x+B*y]=true; } } int cnt=0; for(int i=0;i<(A-1)*(B-1);i++){ if(!found[i])cnt++; } cout << cnt << endl; }else cout << "-1" << endl; return 0; }