比赛 4043级NOIP2022欢乐赛3rd 评测结果 AAAATTTTTT
题目名称 GCD和LCM问题 最终得分 40
用户昵称 HeSn 运行时间 20.035 s
代码语言 C++ 内存使用 10.69 MiB
提交时间 2022-11-04 19:53:26
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 500010;
int n, m, a[MAXN], b[MAXN];
signed main() {
    freopen("gcdlcm.in", "r", stdin);
    freopen("gcdlcm.out", "w", stdout);
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i ++) {
		cin >> b[i];
	}
	for(int i = 1; i <= m; i ++) {
		int op, x, y, w;
		cin >> op >> x >> y;
		if(op == 1) {
			cin >> w;
			for(int j = x; j <= y; j ++) {
				a[j] = w;
			}
		}
		else {
			int minn = 1e12;
			for(int j = x; j <= y; j ++) {
				w = __gcd(a[j], b[j]);
				minn = min(minn, a[j] * b[j] / w / w);
			}
			cout << minn << endl;
		}
	}
	return 0;
}