結果
| 問題 |
No.982 Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-11 21:34:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 346 bytes |
| コンパイル時間 | 423 ms |
| コンパイル使用メモリ | 63,708 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 08:13:11 |
| 合計ジャッジ時間 | 1,150 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int A,B;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ex[10101];
main()
{
cin>>A>>B;
if(gcd(A,B)>1)
{
cout<<-1<<endl;
}
else
{
int cnt=A*B;
for(int x=0;x<=B;x++)for(int y=0;y<=A;y++)
{
int now=x*A+y*B;
if(1<=now&&now<=A*B)
{
cnt-=!ex[now]++;
}
}
cout<<cnt<<endl;
}
}