結果

問題 No.982 Add
ユーザー ゆにぽけゆにぽけ
提出日時 2023-10-31 12:33:47
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 736 bytes
コンパイル時間 1,131 ms
コンパイル使用メモリ 127,152 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-25 17:35:36
合計ジャッジ時間 1,989 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cmath>
#include<ctime>
#include<iomanip>
#include<numeric>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<random>
#include<functional>
#include<utility>
using namespace std;
int gcd(int a,int b)
{
	while(b)
	{
		a %= b;
		swap(a,b);
	}
	return a;
}
int A,B;
void solve()
{
	cin >> A >> B;
	int G = gcd(A,B);
	if(G > 1) cout << -1 << endl;
	else
	{
		int ans = 0;
		for(int i = 0;i < A;i++) ans += i*B/A;
		cout << ans << endl;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	/* cin >> tt; */
	while(tt--) solve();
}
0