Submission #24539749


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

int n, x[55][2];
map<int, pair<long long, long long>> s;
long long ans = 0;

int gcd(int a, int b) {
	while (a) {
		b %= a;
		swap(a, b);
	}
	return b;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", x[i], x[i] + 1);
		for (int j = 0; j < 2; j++)
			for (int k = 1; k * k <= x[i][j]; k++)
				if (x[i][j] % k == 0)
					for (int l : {k, x[i][j] / k}) {
						auto& p = s[l];
						(j == 0 ? p.first : p.second) ^= (1LL << i);
					}
	}
	for (auto& pa : s)
		for (auto& pb : s) {
			long long tmp = (pa.second.first & pb.second.second) | (pa.second.second & pb.second.first);
			if (tmp == (1LL << n) - 1)
				ans = max(ans, (long long)pa.first * pb.first / gcd(pa.first, pb.first));
		}
	printf("%lld\n", ans);
}

Submission Info

Submission Time
Task C - LCM of GCDs
User nhho
Language C++ (GCC 9.2.1)
Score 500
Code Size 828 Byte
Status AC
Exec Time 2352 ms
Memory 4572 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:18:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
./Main.cpp:20:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   20 |   scanf("%d%d", x[i], x[i] + 1);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 73
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, max_01.txt, max_02.txt, max_03.txt, max_04.txt, max_05.txt, max_06.txt, max_07.txt, max_08.txt, max_09.txt, max_10.txt, max_11.txt, max_12.txt, max_13.txt, max_14.txt, max_15.txt, max_16.txt, max_17.txt, max_18.txt, max_19.txt, max_20.txt, max_21.txt, max_22.txt, max_23.txt, max_24.txt, max_25.txt, max_26.txt, max_27.txt, max_28.txt, max_29.txt, max_30.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 132 ms 3664 KiB
hand_02.txt AC 1735 ms 4412 KiB
hand_03.txt AC 1935 ms 4392 KiB
hand_04.txt AC 2352 ms 4572 KiB
hand_05.txt AC 1970 ms 4412 KiB
hand_06.txt AC 1917 ms 4524 KiB
hand_07.txt AC 2016 ms 4420 KiB
hand_08.txt AC 1998 ms 4412 KiB
hand_09.txt AC 2192 ms 4440 KiB
hand_10.txt AC 2019 ms 4556 KiB
max_01.txt AC 24 ms 3684 KiB
max_02.txt AC 147 ms 4008 KiB
max_03.txt AC 13 ms 3760 KiB
max_04.txt AC 412 ms 4120 KiB
max_05.txt AC 73 ms 3896 KiB
max_06.txt AC 155 ms 4116 KiB
max_07.txt AC 16 ms 3780 KiB
max_08.txt AC 24 ms 3796 KiB
max_09.txt AC 16 ms 3644 KiB
max_10.txt AC 154 ms 3932 KiB
max_11.txt AC 263 ms 4048 KiB
max_12.txt AC 80 ms 3900 KiB
max_13.txt AC 47 ms 3852 KiB
max_14.txt AC 383 ms 4148 KiB
max_15.txt AC 25 ms 3800 KiB
max_16.txt AC 1109 ms 4208 KiB
max_17.txt AC 56 ms 3864 KiB
max_18.txt AC 232 ms 4028 KiB
max_19.txt AC 16 ms 3732 KiB
max_20.txt AC 97 ms 3880 KiB
max_21.txt AC 154 ms 4064 KiB
max_22.txt AC 414 ms 4032 KiB
max_23.txt AC 34 ms 3784 KiB
max_24.txt AC 44 ms 3716 KiB
max_25.txt AC 106 ms 3792 KiB
max_26.txt AC 16 ms 3632 KiB
max_27.txt AC 41 ms 3752 KiB
max_28.txt AC 48 ms 3852 KiB
max_29.txt AC 51 ms 3896 KiB
max_30.txt AC 71 ms 3804 KiB
random_01.txt AC 115 ms 3848 KiB
random_02.txt AC 29 ms 3804 KiB
random_03.txt AC 38 ms 3788 KiB
random_04.txt AC 9 ms 3856 KiB
random_05.txt AC 44 ms 3832 KiB
random_06.txt AC 13 ms 3652 KiB
random_07.txt AC 14 ms 3776 KiB
random_08.txt AC 5 ms 3840 KiB
random_09.txt AC 451 ms 4020 KiB
random_10.txt AC 5 ms 3852 KiB
random_11.txt AC 22 ms 3680 KiB
random_12.txt AC 42 ms 3764 KiB
random_13.txt AC 19 ms 3804 KiB
random_14.txt AC 11 ms 3648 KiB
random_15.txt AC 23 ms 3760 KiB
random_16.txt AC 6 ms 3660 KiB
random_17.txt AC 21 ms 3764 KiB
random_18.txt AC 4 ms 3736 KiB
random_19.txt AC 29 ms 3820 KiB
random_20.txt AC 24 ms 3716 KiB
random_21.txt AC 68 ms 3884 KiB
random_22.txt AC 11 ms 3632 KiB
random_23.txt AC 61 ms 3784 KiB
random_24.txt AC 6 ms 3748 KiB
random_25.txt AC 345 ms 4200 KiB
random_26.txt AC 16 ms 3676 KiB
random_27.txt AC 153 ms 3972 KiB
random_28.txt AC 10 ms 3808 KiB
random_29.txt AC 45 ms 3852 KiB
random_30.txt AC 10 ms 3748 KiB
sample_01.txt AC 2 ms 3716 KiB
sample_02.txt AC 5 ms 3660 KiB
sample_03.txt AC 37 ms 3748 KiB