Submission #45542654


Source Code Expand

#include<bits/stdc++.h>
#define LL __int128
#define DB double
#define MOD 1000000007
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T &b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T &b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
	int res = 1;
	while(k)
	{
		if(k & 1) Mul(res, x);
		k >>= 1, Sqr(x);
	}
	return res;
}
void read(LL &x)
{
	x = 0;
	LL f = 1;
	char ch = getchar();
	while(!isdigit(ch))
	{
		if(ch == '-')
			f = -1;
		ch = getchar();
	}
	while(isdigit(ch))
	{
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	x = x * f;
}
void print(LL x)
{
	if(x > 9) print(x / 10);
	putchar('0' + x % 10);
}
LL gcd(LL a, LL b)
{
	if(!b) return a;
	return gcd(b, a % b);
}
LL lcm(LL a, LL b)
{
	LL d = gcd(a, b);
	return a * b / d;
}
const int N = 105;
int n;
LL a[N]; 
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		read(a[i]);
	for(int cas = n; cas >= 1; --cas)
	{
		bool flag = 0;
		for(int i = 1; i <= cas; ++i)
		{
			LL x = a[i];
			LL w = 1;
			for(int j = 1; j <= cas; ++j) 
				if(i != j) w = lcm(w, gcd(x, a[j]));
			if(w < a[i])
			{
				flag = 1;
				int cnt = 0;
				for(int j = 1; j <= cas; ++j)
					if(i != j) a[++cnt] = a[j];
				a[cas] = x;
			}
		}
		if(!flag) return puts("No"), 0;
	}
	puts("Yes");
	for(int i = 1; i <= n; ++i)
	{
		print(a[i]);
		printf(" ");
	}
	return 0;
}

Submission Info

Submission Time
Task E - Increasing LCMs
User Schucking_Sattin
Language C++ 20 (gcc 12.2)
Score 800
Code Size 2343 Byte
Status AC
Exec Time 77 ms
Memory 3892 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:78:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   78 |         scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 3
AC × 35
Set Name Test Cases
Sample 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt
All 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt, 01-024.txt, 01-025.txt, 01-026.txt, 01-027.txt, 01-028.txt, 01-029.txt, 01-030.txt, 01-031.txt, aftercontest-001.txt
Case Name Status Exec Time Memory
00-sample-001.txt AC 1 ms 3668 KiB
00-sample-002.txt AC 1 ms 3664 KiB
00-sample-003.txt AC 1 ms 3620 KiB
01-001.txt AC 1 ms 3684 KiB
01-002.txt AC 10 ms 3700 KiB
01-003.txt AC 1 ms 3696 KiB
01-004.txt AC 6 ms 3704 KiB
01-005.txt AC 34 ms 3644 KiB
01-006.txt AC 37 ms 3700 KiB
01-007.txt AC 32 ms 3552 KiB
01-008.txt AC 5 ms 3584 KiB
01-009.txt AC 5 ms 3892 KiB
01-010.txt AC 1 ms 3624 KiB
01-011.txt AC 1 ms 3672 KiB
01-012.txt AC 62 ms 3664 KiB
01-013.txt AC 1 ms 3684 KiB
01-014.txt AC 10 ms 3660 KiB
01-015.txt AC 40 ms 3720 KiB
01-016.txt AC 1 ms 3556 KiB
01-017.txt AC 77 ms 3780 KiB
01-018.txt AC 73 ms 3764 KiB
01-019.txt AC 68 ms 3712 KiB
01-020.txt AC 56 ms 3768 KiB
01-021.txt AC 57 ms 3720 KiB
01-022.txt AC 76 ms 3684 KiB
01-023.txt AC 74 ms 3720 KiB
01-024.txt AC 67 ms 3660 KiB
01-025.txt AC 56 ms 3704 KiB
01-026.txt AC 45 ms 3764 KiB
01-027.txt AC 76 ms 3728 KiB
01-028.txt AC 73 ms 3584 KiB
01-029.txt AC 68 ms 3664 KiB
01-030.txt AC 56 ms 3720 KiB
01-031.txt AC 25 ms 3680 KiB
aftercontest-001.txt AC 1 ms 3684 KiB