Submission #3352428


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/10/06  Problem: abc112 D / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

VL f(LL n) {
	VL res;
	for (LL i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			res.push_back(i);
			if (n / i != i)res.push_back(n / i);
		}
	}
	SORT(res);
	return res;
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	// (N+K)G=M ,(K≧0) M%G==0
	LL N, M; cin >> N >> M;
	VL divs = f(M);
	LL ans = 0;
	FOR(i, 0, SZ(divs)) {
		LL x = M / divs[i];
		if (x >= N) {
			ans = max(ans, divs[i]);
		}
	}
	cout << ans << "\n";

	return 0;
}

Submission Info

Submission Time
Task D - Partition
User Yang33
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1587 Byte
Status AC
Exec Time 2 ms
Memory 256 KiB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 30
AC × 3
Set Name Test Cases
All 0_small_1, 0_small_2, 0_small_3, 1_large_1, 1_large_2, 1_large_3, 1_large_4, 1_large_5, 1_large_6, 1_large_7, 2_max_1, 2_max_2, 3_prime_1, 3_prime_10, 3_prime_11, 3_prime_2, 3_prime_3, 3_prime_4, 3_prime_5, 3_prime_6, 3_prime_7, 3_prime_8, 3_prime_9, 4_hand_1, 4_hand_2, 4_hand_3, 4_hand_4, sample_01, sample_02, sample_03
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_small_1 AC 1 ms 256 KiB
0_small_2 AC 1 ms 256 KiB
0_small_3 AC 1 ms 256 KiB
1_large_1 AC 1 ms 256 KiB
1_large_2 AC 1 ms 256 KiB
1_large_3 AC 1 ms 256 KiB
1_large_4 AC 1 ms 256 KiB
1_large_5 AC 1 ms 256 KiB
1_large_6 AC 1 ms 256 KiB
1_large_7 AC 2 ms 256 KiB
2_max_1 AC 2 ms 256 KiB
2_max_2 AC 1 ms 256 KiB
3_prime_1 AC 2 ms 256 KiB
3_prime_10 AC 1 ms 256 KiB
3_prime_11 AC 1 ms 256 KiB
3_prime_2 AC 2 ms 256 KiB
3_prime_3 AC 2 ms 256 KiB
3_prime_4 AC 2 ms 256 KiB
3_prime_5 AC 1 ms 256 KiB
3_prime_6 AC 1 ms 256 KiB
3_prime_7 AC 1 ms 256 KiB
3_prime_8 AC 2 ms 256 KiB
3_prime_9 AC 2 ms 256 KiB
4_hand_1 AC 2 ms 256 KiB
4_hand_2 AC 1 ms 256 KiB
4_hand_3 AC 2 ms 256 KiB
4_hand_4 AC 1 ms 256 KiB
sample_01 AC 1 ms 256 KiB
sample_02 AC 1 ms 256 KiB
sample_03 AC 2 ms 256 KiB