problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define ll long long using namespace std; int main() { int n, m; cin >> n >> m; int ans = 0; while (1) { if (m % n == 0) { ans = m / n; break; } n++; } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define ll long long using namespace std; int main() { int n, m; cin >> n >> m; int ans = 1; for (int i = 1; i * i <= m; i++) { if (m % i) continue; if (i >= n) ans = max(ans, m / i); if (m / i >= n) ans = max(ans, i); } cout << ans << endl; }
replace
8
15
8
16
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1}; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } void solve() { int N, M; cin >> N >> M; int ans = 0; for (int i = 1; i * N <= M; i++) { if ((M - i * N) % i == 0) { ans = i; } } cout << ans << endl; } int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1}; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } void solve() { int N, M; cin >> N >> M; int ans = 0; if (N == 1) { cout << M << endl; return; } for (int i = 1; i * N <= M; i++) { if ((M - i * N) % i == 0) { ans = i; } } cout << ans << endl; } int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); solve(); return 0; }
insert
31
31
31
35
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; for (ll i = 1; i <= m; i++) { ll t = m / i; if (m % i == 0 and n * t <= m) { cout << t << endl; return 0; } } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; for (ll i = m / n; i >= 1; i--) { if (m % i == 0 and n * i <= m) { cout << i << endl; return 0; } } }
replace
9
13
9
12
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() #define SZ(x) ((int)(x).size()) using ll = long long; using ull = unsigned long long; using P = pair<int, int>; using llP = pair<ll, ll>; using DoP = pair<double, double>; const int di[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int INF = 1 << 28; const ll INF64 = 1ll << 55; const int mod = 1000000007; // const int mod = 998244353; template <class T> inline bool chmin(T &a, const T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, const T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline void line_out(const vector<T> vec) { int n = SZ(vec); rep(i, n) { cout << vec[i]; if (i < n - 1) cout << " "; } cout << endl; return; } struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint &operator++() { if ((x += 1) >= mod) x -= mod; return *this; } mint &operator--() { if ((x += mod - 1) >= mod) x -= mod; return *this; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main() { ll n, m; cin >> n >> m; int ans; for (ll i = 1; n * i <= m; ++i) { if (m % i == 0) ans = i; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; ++i) #define ALL(a) (a).begin(), (a).end() #define rALL(a) (a).rbegin(), (a).rend() #define SZ(x) ((int)(x).size()) using ll = long long; using ull = unsigned long long; using P = pair<int, int>; using llP = pair<ll, ll>; using DoP = pair<double, double>; const int di[] = {0, 1, 0, -1, 1, 1, -1, -1}; const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int INF = 1 << 28; const ll INF64 = 1ll << 55; const int mod = 1000000007; // const int mod = 998244353; template <class T> inline bool chmin(T &a, const T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, const T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline void line_out(const vector<T> vec) { int n = SZ(vec); rep(i, n) { cout << vec[i]; if (i < n - 1) cout << " "; } cout << endl; return; } struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint &operator++() { if ((x += 1) >= mod) x -= mod; return *this; } mint &operator--() { if ((x += mod - 1) >= mod) x -= mod; return *this; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; int main() { ll n, m; cin >> n >> m; ll ans; for (ll i = m / n;; --i) if (m % i == 0) { cout << i << endl; return 0; } }
replace
106
112
106
112
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() static const int INF(1 << 30); int main() { int N, M; cin >> N >> M; int ans = M / N; while (ans > 1) { int mul = N; while (ans * mul < M) { mul++; } if (ans * mul == M) break; ans--; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() static const int INF(1 << 30); int main() { int N, M; cin >> N >> M; int ans = M / N; while (ans > 1) { // int mul = N; int mul = M / ans - 1; while (ans * mul < M) { mul++; } if (ans * mul == M) break; ans--; } cout << ans << endl; return 0; }
replace
13
14
13
15
TLE
p03241
C++
Time Limit Exceeded
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } template <class T> ostream &operator<<(ostream &out, const vector<T> V) { for (int i = 0; i < V.size(); i++) { out << V[i]; if (i != V.size() - 1) out << " "; } return out; } template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> Mat) { for (int i = 0; i < Mat.size(); i++) { if (i != 0) out << endl; out << Mat[i]; } return out; } template <class S, class T> ostream &operator<<(ostream &out, const map<S, T> mp) { out << "{ "; for (auto it = mp.begin(); it != mp.end(); it++) { out << it->first << ":" << it->second; if (mp.size() - 1 != distance(mp.begin(), it)) out << ", "; } out << " }"; return out; } /* <url:https://atcoder.jp/contests/abc112/tasks/abc112_d> 問題文============================================================ ================================================================= 解説============================================================= ================================================================ */ template <class Type> Type solve(Type res = Type()) { ll N, M; cin >> N >> M; for (ll i = 1; i * N <= M; i++) { if ((M - i * (N - 1)) % i == 0) res = i; } return res; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); // solve(0); cout << fixed << setprecision(15) << solve<ll>() << endl; return 0; }
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } template <class S, class T> ostream &operator<<(ostream &out, const pair<S, T> &o) { out << "(" << o.first << "," << o.second << ")"; return out; } template <class T> ostream &operator<<(ostream &out, const vector<T> V) { for (int i = 0; i < V.size(); i++) { out << V[i]; if (i != V.size() - 1) out << " "; } return out; } template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> Mat) { for (int i = 0; i < Mat.size(); i++) { if (i != 0) out << endl; out << Mat[i]; } return out; } template <class S, class T> ostream &operator<<(ostream &out, const map<S, T> mp) { out << "{ "; for (auto it = mp.begin(); it != mp.end(); it++) { out << it->first << ":" << it->second; if (mp.size() - 1 != distance(mp.begin(), it)) out << ", "; } out << " }"; return out; } /* <url:https://atcoder.jp/contests/abc112/tasks/abc112_d> 問題文============================================================ ================================================================= 解説============================================================= ================================================================ */ template <class Type> Type solve(Type res = Type()) { ll N, M; cin >> N >> M; if (N == 1) return M; for (ll i = 1; i * N <= M; i++) { if ((M - i * (N - 1)) % i == 0) res = i; } return res; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); // solve(0); cout << fixed << setprecision(15) << solve<ll>() << endl; return 0; }
insert
54
54
54
56
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<ll> divisor(ll n) { vector<ll> res; for (ll i = 1; i * i < n; i++) { if (n % i == 0) { res.push_back(i); if (i != n / i) { res.push_back(n / i); } } } return res; } int main() { int n, m; cin >> n >> m; vector<ll> div = divisor(m); sort(div.begin(), div.end()); auto t = *lower_bound(div.begin(), div.end(), n); cout << m / t << endl; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<ll> divisor(ll n) { vector<ll> res; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i != n / i) { res.push_back(n / i); } } } return res; } int main() { int n, m; cin >> n >> m; vector<ll> div = divisor(m); sort(div.begin(), div.end()); auto t = *lower_bound(div.begin(), div.end(), n); cout << m / t << endl; }
replace
7
8
7
8
0
p03241
C++
Runtime Error
#include <algorithm> #include <bitset> #include <cfloat> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; #define int long long #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define FORR(i, a, b) for (ll i = (a); i <= (b); i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define P pair<ll, ll> #define sz(x) (ll) x.size() #define ALL(x) (x).begin(), (x).end() #define ALLR(x) (x).rbegin(), (x).rend() #define VE vector<ll> #define COUT(x) cout << (x) << endl #define MA map<ll, ll> #define SE set<ll> #define PQ priority_queue<ll> #define PQR priority_queue<ll, VE, greater<ll>> #define COUT(x) cout << (x) << endl #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define EPS (1e-10) #define pb push_back const long long MOD = 1000000007; // const long long MOD = 998244353; const long long INF = 1LL << 60; const double PI = acos(-1.0); long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } ll gcd(ll a, ll b) { if (a < b) swap(a, b); if (b == 0) return a; unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; } bool prime(ll n) { for (ll i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } map<ll, ll> prime_factor(ll n) { map<ll, ll> ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } const int MAX = 2000005; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } using Graph = vector<VE>; vector<pair<char, int>> RunLength(string s) { if (s.size() == 0) return {}; vector<pair<char, int>> res(1, pair<char, int>(s[0], 0)); for (char p : s) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { // assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; // comb(2000005); signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; int ans = 0; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { int tmp = i; int tmp2 = n / i; if ((m - tmp * (n - 1)) > 0 && (m - tmp * (n - 1)) % tmp == 0) { chmax(ans, tmp); } if ((m - tmp2 * (n - 1)) > 0 && (m - tmp2 * (n - 1)) % tmp2 == 0) { chmax(ans, tmp2); } } } cout << ans << endl; return 0; }
#include <algorithm> #include <bitset> #include <cfloat> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <list> #include <map> #include <math.h> #include <numeric> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; #define int long long #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define FOR(i, a, b) for (ll i = (a); i < (b); i++) #define FORR(i, a, b) for (ll i = (a); i <= (b); i++) #define repr(i, n) for (ll i = n; i >= 0; i--) #define P pair<ll, ll> #define sz(x) (ll) x.size() #define ALL(x) (x).begin(), (x).end() #define ALLR(x) (x).rbegin(), (x).rend() #define VE vector<ll> #define COUT(x) cout << (x) << endl #define MA map<ll, ll> #define SE set<ll> #define PQ priority_queue<ll> #define PQR priority_queue<ll, VE, greater<ll>> #define COUT(x) cout << (x) << endl #define YES(n) cout << ((n) ? "YES" : "NO") << endl #define Yes(n) cout << ((n) ? "Yes" : "No") << endl #define EPS (1e-10) #define pb push_back const long long MOD = 1000000007; // const long long MOD = 998244353; const long long INF = 1LL << 60; const double PI = acos(-1.0); long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } ll gcd(ll a, ll b) { if (a < b) swap(a, b); if (b == 0) return a; unsigned r; while ((r = a % b)) { a = b; b = r; } return b; } ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; } bool prime(ll n) { for (ll i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return n != 1; } map<ll, ll> prime_factor(ll n) { map<ll, ll> ret; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { ret[i]++; n /= i; } } if (n != 1) ret[n] = 1; return ret; } const int MAX = 2000005; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } using Graph = vector<VE>; vector<pair<char, int>> RunLength(string s) { if (s.size() == 0) return {}; vector<pair<char, int>> res(1, pair<char, int>(s[0], 0)); for (char p : s) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x = 0) : x((x % mod + mod) % mod) {} mint operator-() const { return mint(-x); } mint &operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; } mint &operator-=(const mint a) { if ((x += mod - a.x) >= mod) x -= mod; return *this; } mint &operator*=(const mint a) { (x *= a.x) %= mod; return *this; } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod - 2); } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; struct combination { vector<mint> fact, ifact; combination(int n) : fact(n + 1), ifact(n + 1) { // assert(n < mod); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } }; // comb(2000005); signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; int ans = 0; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { int tmp = i; int tmp2 = m / i; if ((m - tmp * (n - 1)) > 0 && (m - tmp * (n - 1)) % tmp == 0) { chmax(ans, tmp); } if ((m - tmp2 * (n - 1)) > 0 && (m - tmp2 * (n - 1)) % tmp2 == 0) { chmax(ans, tmp2); } } } cout << ans << endl; return 0; }
replace
235
236
235
236
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; int ans = 0; for (int i = 1; i <= M / N; ++i) { if (M % i == 0) { ans = max(ans, i); } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; int ans = 0; if (N == 1) { cout << M << endl; return 0; } for (int i = 1; i <= M / N; ++i) { if (M % i == 0) { ans = max(ans, i); } } cout << ans << endl; }
insert
9
9
9
13
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(20) << fixed; int N, M; cin >> N >> M; int max = 0; for (int i = 1; i <= M / N; i++) { if (M % i == 0 && M % i <= N) { max = i; } } cout << max << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(20) << fixed; int N, M; cin >> N >> M; int max = 0; if (M % N == 0) { cout << M / N << endl; return 0; } for (int i = 1; i <= M / N; i++) { if (M % i == 0 && M % i <= N) { max = i; } } cout << max << endl; }
insert
10
10
10
14
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <climits> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <functional> #include <iomanip> //setprecision #include <iostream> #include <map> // map #include <math.h> #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define ll long long vector<ll> to[1000005]; int main() { ll a, b, c, d; cin >> a >> b; for (ll i = b; i > 0; i--) { if (b % i == 0 && b / i >= a) { cout << i; return 0; } } }
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound #include <bitset> // bitset #include <cctype> // isupper, islower, isdigit, toupper, tolower #include <climits> #include <cstdint> // int64_t, int*_t #include <cstdio> // printf #include <deque> // deque #include <functional> #include <iomanip> //setprecision #include <iostream> #include <map> // map #include <math.h> #include <queue> // queue, priority_queue #include <set> // set #include <stack> // stack #include <string> // string, to_string, stoi #include <tuple> // tuple, make_tuple #include <unordered_map> // unordered_map #include <unordered_set> // unordered_set #include <utility> // pair, make_pair #include <vector> // vector using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define ll long long vector<ll> to[1000005]; int main() { ll a, b, c, d; cin >> a >> b; for (ll i = b / a; i > 0; i--) { if (b % i == 0 && b / i >= a) { cout << i; return 0; } } }
replace
29
30
29
30
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ull unsigned long long #define ld long double #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpii vector<pii> #define vpll vector<pll> #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++) #define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++) #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define RSORT(x) sort(rall(x)); #define pb push_back #define mp make_pair #define INF (1e9) #define PI (acos(-1)) #define EPS (1e-7) ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; } ull lcm(ull a, ull b) { return a / gcd(a, b) * b; } int main() { ll n, m; cin >> n >> m; ll ans = 0; for (ll i = 1; i * 2 <= m; ++i) { if (m % i == 0) { if (m >= n * i) ans = max(ans, i); } } if (m % n == 0) ans = max(ans, m / n); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; #define ull unsigned long long #define ld long double #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpii vector<pii> #define vpll vector<pll> #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++) #define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++) #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); #define RSORT(x) sort(rall(x)); #define pb push_back #define mp make_pair #define INF (1e9) #define PI (acos(-1)) #define EPS (1e-7) ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; } ull lcm(ull a, ull b) { return a / gcd(a, b) * b; } int main() { ll n, m; cin >> n >> m; ll ans = 0; for (ll i = 1; min(i * i, i * 16) <= m; ++i) { if (m % i == 0) { if (m >= n * i) ans = max(ans, i); } } if (m % n == 0) ans = max(ans, m / n); cout << ans << endl; return 0; }
replace
43
44
43
44
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int n, m; cin >> n >> m; for (int i = m; i >= 1; i--) { if (m % i == 0) { if (m / i >= n) { cout << i << endl; return 0; } } } }
#include <algorithm> #include <iostream> #include <math.h> #include <queue> #include <string.h> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { int n, m; cin >> n >> m; for (int i = m / n + 1; i >= 1; i--) { if (m % i == 0) { if (m / i >= n) { cout << i << endl; return 0; } } } }
replace
14
15
14
15
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> // #include <mylib.h> using namespace std; // cin.sync_with_stdio(false); #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FOR_EQ(i, a, b) for (int i = (a); i <= (b); ++i) #define FOR_RE(i, a, b) for (int i = (a); i > (b); --i) #define rep(i, n) FOR(i, 0, n) #define rep_eq(i, n) FOR_EQ(i, 0, n) #define rep_re(i, n) FOR_RE(i, n, 0) #define WHITE 1 // (未訪問) #define GRAY \ 2 // (訪問)未だに訪問していない頂点への辺を持っている。スタックに退避。 #define BLACK 3 // (訪問完了)未訪問への頂点への辺を持たない #define N 100 #define INFTY (1 << 21) // 10^21 int M[N][N]; // 隣接行列 int color[N]; // 1個上から時計周り const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; // 上右下左 const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; static const int NIL = -1; typedef unsigned long long ull; typedef long long ll; typedef vector<int> Vector; typedef vector<Vector> DVector; int n; // 配列の表示 void printArray(int array[], int n) { rep(i, n) { if (i) cout << " "; cout << array[i]; } cout << endl; } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); int m; cin >> n >> m; ll gcd; ll tmp; rep_re(i, m) { if (m % i == 0) { gcd = i; tmp = gcd * n; if (tmp <= m) { // cout << tmp << endl; cout << gcd << endl; return 0; } } } }
#include <bits/stdc++.h> // #include <mylib.h> using namespace std; // cin.sync_with_stdio(false); #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FOR_EQ(i, a, b) for (int i = (a); i <= (b); ++i) #define FOR_RE(i, a, b) for (int i = (a); i > (b); --i) #define rep(i, n) FOR(i, 0, n) #define rep_eq(i, n) FOR_EQ(i, 0, n) #define rep_re(i, n) FOR_RE(i, n, 0) #define WHITE 1 // (未訪問) #define GRAY \ 2 // (訪問)未だに訪問していない頂点への辺を持っている。スタックに退避。 #define BLACK 3 // (訪問完了)未訪問への頂点への辺を持たない #define N 100 #define INFTY (1 << 21) // 10^21 int M[N][N]; // 隣接行列 int color[N]; // 1個上から時計周り const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1}; // 上右下左 const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; static const int NIL = -1; typedef unsigned long long ull; typedef long long ll; typedef vector<int> Vector; typedef vector<Vector> DVector; int n; // 配列の表示 void printArray(int array[], int n) { rep(i, n) { if (i) cout << " "; cout << array[i]; } cout << endl; } int main(int argc, char const *argv[]) { cin.tie(0); ios::sync_with_stdio(false); int m; cin >> n >> m; ll gcd; ll tmp; ll d = m / n; rep_re(i, d) { if (m % i == 0) { gcd = i; tmp = gcd * n; if (tmp <= m) { // cout << tmp << endl; cout << gcd << endl; return 0; } } } }
replace
53
55
53
55
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N, M; cin >> N >> M; int ans = 0; for (int g = 1; g * N <= M; g++) { if (M % g == 0) { ans = max(ans, g); } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N, M; cin >> N >> M; int ans = 0; if (M % N == 0) { cout << M / N << endl; return 0; } for (int g = 1; g * N <= M; g++) { if (M % g == 0) { ans = max(ans, g); } } cout << ans << endl; }
insert
8
8
8
12
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <string> using namespace std; int R(int Cx, int Cy, int x, int y) { return abs(x - Cx) + abs(y - Cy); } int main(void) { int N, M, ans; cin >> N >> M; if (N == 1) ans = M; else if (N == 2 && M % 2 == 0) ans = M / 2; for (long int n = 1; n <= M / N + 2; n++) { if (M % n == 0 && M / n >= N) ans = n; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <functional> #include <iostream> #include <string> using namespace std; int R(int Cx, int Cy, int x, int y) { return abs(x - Cx) + abs(y - Cy); } int main(void) { int N, M, ans; cin >> N >> M; if (N == 1) ans = M; else if (N == 2 && M % 2 == 0) ans = M / 2; else if (N == 3 && M % 3 == 0) ans = M / 3; else { for (long int n = 1; n <= M / N + 2; n++) { if (M % n == 0 && M / n >= N) ans = n; } } cout << ans << endl; return 0; }
replace
14
17
14
21
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typedef vector<long long> vll, vLL; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < n; ++i) #define mod (ll)(1e9 + 7) #define ALL(obj) (obj).begin(), (obj).end() #define INF 1000000000 // 1e9 #define LLINF 2000000000000000000LL // 2e18 #define fi first #define se second #define pb push_back int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; for (ll i = m; i > 0; i--) { if (m % i == 0) { if (m / i >= n) { cout << i << endl; return 0; } } } return 0; }
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> vint; typedef vector<vector<int>> vvint; typedef vector<long long> vll, vLL; typedef vector<long long> vll, vLL; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < n; ++i) #define mod (ll)(1e9 + 7) #define ALL(obj) (obj).begin(), (obj).end() #define INF 1000000000 // 1e9 #define LLINF 2000000000000000000LL // 2e18 #define fi first #define se second #define pb push_back int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; for (ll i = m / n; i > 0; i--) { if (m % i == 0) { if (m / i >= n) { cout << i << endl; return 0; } } } return 0; }
replace
29
30
29
30
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = M; i > 0; i--) { if (M % i == 0 && M / i >= N) { cout << i << endl; break; } } }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = M / N; i > 0; i--) { if (M % i == 0) { cout << i << endl; break; } } }
replace
5
7
5
7
TLE
p03241
C++
Time Limit Exceeded
using namespace std; #include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> typedef pair<int, int> ii; typedef vector<int> vi; int n, m; int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); } signed main() { scanf("%d%d", &n, &m); int mx = (m / n) + 1; int ans = 1, mod; int s = sqrt(m) + 1.; if (n == 1) printf("%d\n", m); else if (m % n == 0) printf("%d\n", m / n); else if (mx <= 70000000) { for (int i = 2; i < mx; i++) { mod = m - (i * (n - 1)); ans = max(ans, gcd(mod, i)); } printf("%d\n", ans); } else { for (int i = 2; i < s; i++) { if (m % i == 0) { if (i < mx) ans = max(i, ans); if (m / i < mx) ans = max(m / i, ans); } } printf("%d\n", ans); } }
using namespace std; #include <algorithm> #include <iostream> #include <map> #include <math.h> #include <set> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <vector> typedef pair<int, int> ii; typedef vector<int> vi; int n, m; int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); } signed main() { scanf("%d%d", &n, &m); int mx = (m / n) + 1; int ans = 1, mod; int s = sqrt(m) + 1.; if (n == 1) printf("%d\n", m); else if (m % n == 0) printf("%d\n", m / n); else if (mx <= 50000000) { for (int i = 2; i < mx; i++) { mod = m - (i * (n - 1)); ans = max(ans, gcd(mod, i)); } printf("%d\n", ans); } else { for (int i = 2; i < s; i++) { if (m % i == 0) { if (i < mx) ans = max(i, ans); if (m / i < mx) ans = max(m / i, ans); } } printf("%d\n", ans); } }
replace
29
30
29
30
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair<int, int> P; vector<ll> frac(ll n) { vector<ll> res; res.clear(); for (ll i = 2LL; i * i <= n; ++i) { if (n % i == 0LL) { res.push_back(i); if (i * i < n) { res.push_back(n / i); } // end if } // end if } // end for sort(ALL(res)); return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll N, M; cin >> N >> M; vector<ll> f = frac(M); int ind1 = lower_bound(ALL(f), M / N) - f.begin(); int ind2 = upper_bound(ALL(f), M / N) - f.begin(); ll res = 0LL; if (ind1 == ind2) { // M / N より大きい res = f[ind1 - 1]; } else { // M / N に等しい res = f[ind1]; } // end if cout << res << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair<int, int> P; vector<ll> frac(ll n) { vector<ll> res; res.clear(); for (ll i = 1LL; i * i <= n; ++i) { if (n % i == 0LL) { res.push_back(i); if (i * i < n) { res.push_back(n / i); } // end if } // end if } // end for sort(ALL(res)); return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll N, M; cin >> N >> M; vector<ll> f = frac(M); int ind1 = lower_bound(ALL(f), M / N) - f.begin(); int ind2 = upper_bound(ALL(f), M / N) - f.begin(); ll res = 0LL; if (ind1 == ind2) { // M / N より大きい res = f[ind1 - 1]; } else { // M / N に等しい res = f[ind1]; } // end if cout << res << endl; return 0; }
replace
12
13
12
13
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1000000007; const int INF = 1001001001; int main() { int n, m; cin >> n >> m; for (int i = n; i < m; i++) { if (m % i == 0) { cout << m / i << endl; return 0; } } cout << 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1000000007; const int INF = 1001001001; int main() { int n, m; cin >> n >> m; for (int i = n; i <= (m / 2); i++) { if (m % i == 0) { cout << m / i << endl; return 0; } } cout << 1 << endl; return 0; }
replace
9
10
9
10
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000007; int main() { // K(a1+a2+…aN)=M // M/K>=N&&M%K=0 int N, K; cin >> N >> K; for (int i = K; i >= 1; i--) { if (K % i == 0 && K / i >= N) { cout << i; return 0; } } }
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000007; int main() { // K(a1+a2+…aN)=M // M/K>=N&&M%K=0 int N, K; cin >> N >> K; for (int i = K / N; i >= 1; i--) { if (K % i == 0 && K / i >= N) { cout << i; return 0; } } }
replace
9
10
9
10
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef pair<ll, P> PP; const ll INF = 1LL << 60; const ll MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; vector<ll> divisors; for (ll i = 1; i <= M; ++i) { if (M % i == 0) { if (M / i < i) break; if (M / i == i) { divisors.push_back(i); break; } divisors.push_back(i); divisors.push_back(M / i); } } ll ans = 0; ll tmp = M / N; for (auto &d : divisors) { if (d <= tmp) { chmax(ans, d); } } cout << ans << endl; // system("pause"); }
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <tuple> #include <unordered_map> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef pair<ll, P> PP; const ll INF = 1LL << 60; const ll MOD = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; vector<ll> divisors; for (ll i = 1; i <= sqrt(M); ++i) { if (M % i == 0) { if (M / i < i) break; if (M / i == i) { divisors.push_back(i); break; } divisors.push_back(i); divisors.push_back(M / i); } } ll ans = 0; ll tmp = M / N; for (auto &d : divisors) { if (d <= tmp) { chmax(ans, d); } } cout << ans << endl; // system("pause"); }
replace
50
51
50
51
TLE
p03241
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; int ma = m / n; int sum = 0; int ans = -1; for (int j = ma; j > 0; j--) { sum = 0; sum += j * n; if (sum > m) continue; else if (sum <= m) { while (sum < m) { sum += j; } } if (sum == m) { ans = j; break; } } cout << ans << endl; }
#include <iostream> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; int ma = m / n; int sum = 0; int ans = -1; for (int j = ma; j > 0; j--) { if (m % j == 0) { ans = j; break; } } cout << ans << endl; }
replace
11
21
11
12
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (m % n == 0) { cout << m / n; return 0; } int res = 1; for (int i = 2; i <= m; i++) { if (m % i == 0 && m / i >= n) { res = max(res, i); } } cout << res; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if (m % n == 0) { cout << m / n; return 0; } int res = 1; for (int i = 2; m / i >= n; i++) { if (m % i == 0) { res = max(res, i); } } cout << res; }
replace
12
14
12
14
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int n, m; int main() { while (scanf("%d %d", &n, &m) != EOF) { int ans = 0; int t = m / n; for (int i = 1; i <= t; i++) { if (m / i >= n && m % i == 0) ans = max(ans, i); } printf("%d\n", ans); } }
#include <bits/stdc++.h> using namespace std; int n, m; int main() { while (scanf("%d %d", &n, &m) != EOF) { int ans = 0; if (m % n == 0) ans = m / n; else { int t = m / n; for (int i = 1; i <= t; i++) { if (m % i == 0 && i <= m / n) ans = max(ans, i); } } printf("%d\n", ans); } }
replace
7
11
7
15
TLE
p03241
C++
Time Limit Exceeded
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; int dy4[4] = {-1, 0, +1, 0}; int dx4[4] = {0, +1, 0, -1}; int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const long long INF = 1LL << 60; const ll MOD = 1e9 + 7; bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) { return f.second > s.second; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll nCr(ll n, ll r) { if (r == 0 || r == n) { return 1; } else if (r == 1) { return n; } return (nCr(n - 1, r) + nCr(n - 1, r - 1)); } ll nPr(ll n, ll r) { r = n - r; ll ret = 1; for (ll i = n; i >= r + 1; i--) ret *= i; return ret; } //-----------------------ここから----------- int main(void) { int n, m; cin >> n >> m; int ans = 0; for (int i = 1; i * n <= m; i++) { if (m % i == 0) { ans = i; } } cout << ans << endl; }
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; int dy4[4] = {-1, 0, +1, 0}; int dx4[4] = {0, +1, 0, -1}; int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const long long INF = 1LL << 60; const ll MOD = 1e9 + 7; bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) { return f.second > s.second; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll nCr(ll n, ll r) { if (r == 0 || r == n) { return 1; } else if (r == 1) { return n; } return (nCr(n - 1, r) + nCr(n - 1, r - 1)); } ll nPr(ll n, ll r) { r = n - r; ll ret = 1; for (ll i = n; i >= r + 1; i--) ret *= i; return ret; } //-----------------------ここから----------- int main(void) { int n, m; cin >> n >> m; int ans = 0; if (n == 1) { cout << m << endl; return 0; } for (int i = 1; i * n <= m; i++) { if (m % i == 0) { ans = i; } } cout << ans << endl; }
insert
69
69
69
74
TLE
p03241
C++
Time Limit Exceeded
#include <iostream> using namespace std; int sumf(int m) { int r = 0; for (int i = 1; i < m + 1; i++) r += i; return r; } int main() { int p, q; cin >> p >> q; int m = 0; for (int i = 1; i <= q / p; i++) { if (q % i == 0) m = i; } cout << m << endl; return 0; }
#include <iostream> using namespace std; int sumf(int m) { int r = 0; for (int i = 1; i < m + 1; i++) r += i; return r; } int main() { int p, q; cin >> p >> q; int m = 0; if (p != 1) { for (int i = 1; i <= q / p; i++) { if (q % i == 0) m = i; } } else { m = q; } cout << m << endl; return 0; }
replace
13
16
13
20
TLE
p03241
Python
Time Limit Exceeded
# a1 + a2 + a3 ... + an = M # ai の 最大公約数をDとする # ai = xi * D のはず。 D * x0 + D * x1 ... + D * xn = M # まとめて D(x1 + x2 + .... + xn) = M # 変形し、D = M / (x1 + x2 + .... + xn) # (x1 + ... xn) = K とすると、Kを最小化するとDが最大化する # M / K が割り切れる必要があるので、KはMの約数のいずれか # K >= N。なぜなら xi >= 1 なので、Kは最低でも数字の個数 N になる # つまり、約数のうちで N 以上の最初の値が K になる # ex: 3 14 # 14 の約数 {1, 2, 7} # K >= N なので、 K >= 3 # K = 7 で確定。つまり D = M/K = 2 でAnswer N, M = map(int, input().split()) for i in range(1, M + 1): if M % i == 0 and i >= N: print(M // i) break
# a1 + a2 + a3 ... + an = M # ai の 最大公約数をDとする # ai = xi * D のはず。 D * x0 + D * x1 ... + D * xn = M # まとめて D(x1 + x2 + .... + xn) = M # 変形し、D = M / (x1 + x2 + .... + xn) # (x1 + ... xn) = K とすると、Kを最小化するとDが最大化する # M / K が割り切れる必要があるので、KはMの約数のいずれか # K >= N。なぜなら xi >= 1 なので、Kは最低でも数字の個数 N になる # つまり、約数のうちで N 以上の最初の値が K になる # ex: 3 14 # 14 の約数 {1, 2, 7} # K >= N なので、 K >= 3 # K = 7 で確定。つまり D = M/K = 2 でAnswer N, M = map(int, input().split()) M_ROOT = int(M**0.5) k = M for i in range(1, M_ROOT + 1): if M % i == 0: if i >= N: print(M // i) exit() d = M // i if d < k and d >= N: k = d print(M // k)
replace
15
19
15
26
TLE
p03241
Python
Runtime Error
N, M = map(int, input().split()) if N == 1: print(M) else: ans = 1 for g in range(1, int(M**0.5) + 1): if M % g == 0 and M / g >= N: ans = g print(ans)
N, M = map(int, input().split()) ans = 1 for g in range(1, int(M**0.5) + 1): if M % g == 0 and M / g >= N: ans = max(ans, g) if M % g == 0: g2 = M // g if M % g2 == 0 and M / g2 >= N: ans = max(ans, g2) print(ans)
replace
2
9
2
11
0
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <sstream> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define range(i, n, m) for (int i = n; i < m; i++) #define rrange(i, n, m) for (int i = n - 1; i = > m; i--) #define MOD 1000000007; typedef long long int ll; typedef unsigned long long int ull; using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; rrep(i, M + 1) { if (M % i == 0 && M / i >= N) { cout << dec << i; break; } } return 0; }
#include <algorithm> #include <cmath> #include <cstring> #include <iomanip> #include <iostream> #include <iterator> #include <sstream> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = n - 1; i >= 0; i--) #define range(i, n, m) for (int i = n; i < m; i++) #define rrange(i, n, m) for (int i = n - 1; i = > m; i--) #define MOD 1000000007; typedef long long int ll; typedef unsigned long long int ull; using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll N, M; cin >> N >> M; rrep(i, M / N + 1) { if (M % i == 0 && M / i >= N) { cout << dec << i; break; } } return 0; }
replace
36
37
36
37
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, m, ans; cin >> n >> m; for (int i = 1; i <= m / n; ++i) { if (m % i == 0 && m / i >= n) ans = i; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m, ans; cin >> n >> m; if (n == 1) { cout << m; return 0; } for (int i = 1; i <= m / n; ++i) { if (m % i == 0 && m / i >= n) ans = i; } cout << ans; return 0; }
insert
5
5
5
9
TLE
p03241
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() using namespace std; int main(void) { int n, m; cin >> n >> m; if (m % n == 0) { cout << m / n; return 0; } int k = m / n; int l = m % n; int a = 1; while (true) { if ((n * a + l) % (k - a) == 0) break; a++; } cout << k - a; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <numeric> #include <vector> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() using namespace std; int main(void) { int n, m; cin >> n >> m; if (m % n == 0) { cout << m / n; return 0; } if (m / n == 1) { cout << 1; return 0; } int k = m / n; int l = m % n; int a = 1; while (true) { if ((n * a + l) % (k - a) == 0) break; a++; } cout << k - a; return 0; }
insert
18
18
18
22
0
p03241
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; typedef long long ll; typedef vector<ll> vl; vector<pair<ll, ll>> factorize(ll N) { vector<pair<ll, ll>> res; ll n = N; for (ll p = 2; p * p <= n; p++) { if (N % p != 0) continue; int count = 0; while (N % p == 0) { count++; // pで割れる回数をカウント N /= p; } res.push_back(make_pair(p, count)); } if (N != 1) res.push_back(make_pair(N, 1)); // 最終的にNが素数のとき return res; } vl getFactors(ll N) { vector<pair<ll, ll>> f = factorize(N); vl res; res.push_back(1); for (int i = 0; i < f.size(); i++) { int s = res.size(); for (int j = 0; j < s; j++) for (int k = 0; k < f[i].second; k++) { res.push_back(res[j] * pow(f[i].first, k + 1)); } } sort(res.begin(), res.end()); return res; } int main() { ll N, M; cin >> N >> M; vl factors = getFactors(M); for (int i = factors.size() - 1; i >= 0; i--) { if (M / i >= N) { cout << i << endl; return 0; } } return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; typedef long long ll; typedef vector<ll> vl; vector<pair<ll, ll>> factorize(ll N) { vector<pair<ll, ll>> res; ll n = N; for (ll p = 2; p * p <= n; p++) { if (N % p != 0) continue; int count = 0; while (N % p == 0) { count++; // pで割れる回数をカウント N /= p; } res.push_back(make_pair(p, count)); } if (N != 1) res.push_back(make_pair(N, 1)); // 最終的にNが素数のとき return res; } vl getFactors(ll N) { vector<pair<ll, ll>> f = factorize(N); vl res; res.push_back(1); for (int i = 0; i < f.size(); i++) { int s = res.size(); for (int j = 0; j < s; j++) for (int k = 0; k < f[i].second; k++) { res.push_back(res[j] * pow(f[i].first, k + 1)); } } sort(res.begin(), res.end()); return res; } int main() { ll N, M; cin >> N >> M; vl factors = getFactors(M); for (int i = factors.size() - 1; i >= 0; i--) { if (M / factors[i] >= N) { cout << factors[i] << endl; return 0; } } return 0; }
replace
48
50
48
50
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define llong long long int #define ldouble long double #define ternary(condition, x, y) ((condition) ? x : y) #define rep(i, n) for (int i = 0; i < n; ++i) #define all(x) x.begin(), x.end() #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) const static long long int MOD = 1000000000 + 7; const static int dy[] = {0, 1, 0, -1}; const static int dx[] = {1, 0, -1, 0}; int main(int argc, char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); llong n, m; cin >> n >> m; if (m % n == 0) { cout << m / n << endl; return 0; } llong ans = 0; for (int i = m; i > 0; --i) { if (m % i == 0 && n * i <= m) { ans = i; break; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define llong long long int #define ldouble long double #define ternary(condition, x, y) ((condition) ? x : y) #define rep(i, n) for (int i = 0; i < n; ++i) #define all(x) x.begin(), x.end() #define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr) const static long long int MOD = 1000000000 + 7; const static int dy[] = {0, 1, 0, -1}; const static int dx[] = {1, 0, -1, 0}; int main(int argc, char *argv[]) { cin.tie(0); ios::sync_with_stdio(false); llong n, m; cin >> n >> m; if (m % n == 0) { cout << m / n << endl; return 0; } llong ans = 0; for (llong i = m; i > 0; --i) { if (n * i <= m) { if (m % i == 0) { ans = i; break; } } } cout << ans << endl; return 0; }
replace
27
31
27
33
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int ans = 1; for (int i = 1; i <= M; i++) { if (M % i == 0 && M / i >= N) ans = i; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int ans = 1; for (int i = 1; i * i <= M; i++) { if (M % i == 0) { if (M / i >= N) ans = max(ans, i); if (i >= N) ans = max(ans, M / i); } } cout << ans << endl; }
replace
7
10
7
14
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <climits> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; int main(void) { long long int n, m; cin >> n >> m; long long int ans = 1; if (m % n == 0) { cout << m / n << endl; return 0; } else { for (long long int i = 2; i <= m; i++) { if (m % i == 0) { if (m / i > n) ans = i; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <climits> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <utility> #include <vector> using namespace std; int main(void) { long long int n, m; cin >> n >> m; long long int ans = 1; if (m % n == 0) { cout << m / n << endl; return 0; } else { for (long long int i = 2; i <= m; i++) { if (m % i == 0) { if (m / i > n) ans = i; } if (m / i < n) break; } } cout << ans << endl; return 0; }
insert
29
29
29
32
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define DEBUG // 素数列を作る // N: 上限 // v: 出力先 void GetPrimes(int N, vector<int> &v) { v = vector<int>(); int c = 1; while (c < N) { c++; bool flag = true; int d = (int)sqrt(c); for (int i = 0; i < v.size(); i++) { if (c % v[i] == 0) { flag = false; break; } if (d < v[i]) break; } if (flag) v.push_back(c); } } // 素因数分解を行う // N: 対象 // p: 素数セット(GetPrimesで取得) // v: 導かれた指数部 // [return]: 割り切れない場合の残り, 失敗すると-1を返す int64_t Factorize(int64_t N, const vector<int> &p, vector<int> &v) { if (p.back() < sqrt(N)) return -1; for (int i = 0; N != 1 && i < p.size(); i++) { v.push_back(0); while (N % p[i] == 0) { N /= p[i]; v[i]++; } } return N; } int64_t N, M, L, ans = 0; vector<int> P; vector<int> F; void recursive(int k, int64_t n) { if (M < n * N) return; if (k == -1) { ans = max(n, ans); return; } int64_t tmp = 1; for (int i = 0; i <= F[k]; i++) { recursive(k - 1, n * tmp); tmp *= P[k]; } } int main() { #ifdef DEBUG std::ifstream in("/home/share/inputf.in"); std::cin.rdbuf(in.rdbuf()); #endif cin >> N >> M; GetPrimes(100000, P); Factorize(M, P, F); L = F.size(); recursive(L - 1, 1); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; // 素数列を作る // N: 上限 // v: 出力先 void GetPrimes(int N, vector<int> &v) { v = vector<int>(); int c = 1; while (c < N) { c++; bool flag = true; int d = (int)sqrt(c); for (int i = 0; i < v.size(); i++) { if (c % v[i] == 0) { flag = false; break; } if (d < v[i]) break; } if (flag) v.push_back(c); } } // 素因数分解を行う // N: 対象 // p: 素数セット(GetPrimesで取得) // v: 導かれた指数部 // [return]: 割り切れない場合の残り, 失敗すると-1を返す int64_t Factorize(int64_t N, const vector<int> &p, vector<int> &v) { if (p.back() < sqrt(N)) return -1; for (int i = 0; N != 1 && i < p.size(); i++) { v.push_back(0); while (N % p[i] == 0) { N /= p[i]; v[i]++; } } return N; } int64_t N, M, L, ans = 0; vector<int> P; vector<int> F; void recursive(int k, int64_t n) { if (M < n * N) return; if (k == -1) { ans = max(n, ans); return; } int64_t tmp = 1; for (int i = 0; i <= F[k]; i++) { recursive(k - 1, n * tmp); tmp *= P[k]; } } int main() { #ifdef DEBUG std::ifstream in("/home/share/inputf.in"); std::cin.rdbuf(in.rdbuf()); #endif cin >> N >> M; GetPrimes(100000, P); Factorize(M, P, F); L = F.size(); recursive(L - 1, 1); cout << ans << endl; return 0; }
delete
2
4
2
2
TLE
p03241
C++
Time Limit Exceeded
// include,using,define等 #pragma region header #include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // =============================================================== // using系 #pragma region header using namespace std; using ll = long long; using lint = long long; using vl = vector<long long>; using vvl = vector<vector<long long>>; using vvi = vector<vector<int>>; using vs = vector<string>; using vc = vector<char>; using vcc = vector<vector<char>>; using vm = vector<short>; using vmm = vector<vector<short>>; using pii = pair<int, int>; using psi = pair<string, int>; using ld = long double; using ull = unsigned long long; using ui = unsigned int; using qul = queue<ll>; using pql = priority_queue<ll>; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; constexpr ll mod = 1e9 + 7; constexpr long double pi = 3.141592653589793238462643383279; #pragma endregion // ======================================================================== // define #pragma region header // #define int long long #define rep(i, n) for (ll i = 0; i < n; i++) #define REP(i, n) for (ll i = 1; i <= n; i++) #define INF (ll)10000000000000000 #define mod (ll)1000000007 #define P pair<lint, lint> #pragma endregion #pragma endregion int main() { lint n, m; cin >> n >> m; lint ans = 1; for (int i = 1; i < m / n + 2; i++) { if (m % i == 0 && m / i >= n) { ans = i; } } printf("%lld\n", ans); return 0; }
// include,using,define等 #pragma region header #include <algorithm> #include <assert.h> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdint> #include <cstring> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <math.h> #include <memory> #include <queue> #include <random> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string> #include <tuple> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> // =============================================================== // using系 #pragma region header using namespace std; using ll = long long; using lint = long long; using vl = vector<long long>; using vvl = vector<vector<long long>>; using vvi = vector<vector<int>>; using vs = vector<string>; using vc = vector<char>; using vcc = vector<vector<char>>; using vm = vector<short>; using vmm = vector<vector<short>>; using pii = pair<int, int>; using psi = pair<string, int>; using ld = long double; using ull = unsigned long long; using ui = unsigned int; using qul = queue<ll>; using pql = priority_queue<ll>; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; constexpr ll mod = 1e9 + 7; constexpr long double pi = 3.141592653589793238462643383279; #pragma endregion // ======================================================================== // define #pragma region header // #define int long long #define rep(i, n) for (ll i = 0; i < n; i++) #define REP(i, n) for (ll i = 1; i <= n; i++) #define INF (ll)10000000000000000 #define mod (ll)1000000007 #define P pair<lint, lint> #pragma endregion #pragma endregion int main() { lint n, m; cin >> n >> m; lint ans = 1; if (n == 1) { printf("%d\n", m); return 0; } for (int i = 1; i < m / n + 2; i++) { if (m % i == 0 && m / i >= n) { ans = i; } } printf("%lld\n", ans); return 0; }
insert
80
80
80
84
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long using namespace std; int main() { int n, m; cin >> n >> m; int end = m / n; int ans = 1; for (int i = 2; i <= end; i++) { int tmp = m - (n - 1) * i; if (tmp % i == 0) { ans = i; } } cout << ans << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define ll long long using namespace std; int main() { int n, m; cin >> n >> m; int end = m / n; int ans = 1; vector<int> v; for (int i = 1; i * i <= m && i <= end; i++) { if (m % i == 0) { v.push_back(i); if (m / i <= end) { v.push_back(m / i); } } } for (auto e : v) { int tmp = m - (n - 1) * e; if (tmp % e == 0) { ans = max(ans, e); } } cout << ans << endl; }
replace
9
13
9
22
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina cout << ' ' #define in(n) cin >> n #define in2(n, m) cin >> n >> m #define in3(n, m, l) cin >> n >> m >> l #define out(n) cout << n const ll mei = (ll)1e9 + 7; int main() { ll n, m, a; in2(n, m); rep2(i, 1, 210000000) { if (m % i == 0) { if (n * i <= m) a = max(a, i); if (n * (m / i) <= m) a = max(a, (m / i)); } } out(a); memi; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina cout << ' ' #define in(n) cin >> n #define in2(n, m) cin >> n >> m #define in3(n, m, l) cin >> n >> m >> l #define out(n) cout << n const ll mei = (ll)1e9 + 7; int main() { ll n, m, a; in2(n, m); rep2(i, 1, 191000000) { if (m % i == 0) { if (n * i <= m) a = max(a, i); if (n * (m / i) <= m) a = max(a, (m / i)); } } out(a); memi; }
replace
19
20
19
20
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; // M/N以下のMの最大の約数dじゃね? // K=M/dとしたとき、K>=N // Kをd個の整数に分けるのはeasyじゃん // 間に合うかな int MAX = 1; for (int i = 1; i <= (M / N); i++) { if (M % i == 0) MAX = i; } cout << MAX << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; // M/N以下のMの最大の約数dじゃね? // K=M/dとしたとき、K>=N // Kをd個の整数に分けるのはeasyじゃん // 間に合うかな int MAX = 1; for (int i = 1; i * i <= M; i++) { if (M % i != 0) continue; if (M / i <= M / N) MAX = max(M / i, MAX); else if (i <= M / N) MAX = max(MAX, i); } cout << MAX << endl; }
replace
14
17
14
21
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina cout << ' ' #define in(n) cin >> n #define in2(n, m) cin >> n >> m #define in3(n, m, l) cin >> n >> m >> l #define out(n) cout << n const ll mei = (ll)1e9 + 7; int main() { ll n, m, a; in2(n, m); rep2(i, 1, 198000000) { if (m % i == 0) { if (n * i <= m) a = max(a, i); if (n * (m / i) <= m) a = max(a, (m / i)); } } out(a); memi; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define rep2(i, a, n) for (ll i = a; i < (ll)(n); i++) #define memi cout << endl #define kono(n) cout << fixed << setprecision(n) #define all(c) (c).begin(), (c).end() #define pb push_back #define hina cout << ' ' #define in(n) cin >> n #define in2(n, m) cin >> n >> m #define in3(n, m, l) cin >> n >> m >> l #define out(n) cout << n const ll mei = (ll)1e9 + 7; int main() { ll n, m, a; in2(n, m); rep2(i, 1, 185000000) { if (m % i == 0) { if (n * i <= m) a = max(a, i); if (n * (m / i) <= m) a = max(a, (m / i)); } } out(a); memi; }
replace
19
20
19
20
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return abs(a * b) / gcd(a, b); } std::vector<bool> IsPrime; void sieve(size_t max) { if (max + 1 > IsPrime.size()) IsPrime.resize(max + 1, true); IsPrime[0] = false; IsPrime[1] = false; for (size_t i = 2; i * i <= max; ++i) if (IsPrime[i]) for (size_t j = 2; i * j <= max; ++j) IsPrime[i * j] = false; } #define roundup(divisor, dividend) (divisor + (dividend - 1)) / dividend #define all(x) (x).begin(), (x).end() #define size_t ll const int mod = 1000000007; /* 確認ポイント cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる vector.unique()は隣接した同じ要素を削除するので先にソートをする 計算量は変わらないが楽できるシリーズ C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる */ ll n, m; ll ans = 0; int main() { cin >> n >> m; for (size_t i = 1; i <= roundup(m, n); i++) { if (m % i == 0) ans = i; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long; ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return abs(a * b) / gcd(a, b); } std::vector<bool> IsPrime; void sieve(size_t max) { if (max + 1 > IsPrime.size()) IsPrime.resize(max + 1, true); IsPrime[0] = false; IsPrime[1] = false; for (size_t i = 2; i * i <= max; ++i) if (IsPrime[i]) for (size_t j = 2; i * j <= max; ++j) IsPrime[i * j] = false; } #define roundup(divisor, dividend) (divisor + (dividend - 1)) / dividend #define all(x) (x).begin(), (x).end() #define size_t ll const int mod = 1000000007; /* 確認ポイント cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる vector.unique()は隣接した同じ要素を削除するので先にソートをする 計算量は変わらないが楽できるシリーズ C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる */ ll n, m; ll ans = 0; int main() { cin >> n >> m; for (ll i = 1; pow(i, 2) <= m; i++) { if (m % i != 0) continue; if (i <= m / n) ans = max(i, ans); if ((m / i) <= (m / n)) ans = max(m / i, ans); } cout << ans << endl; }
replace
35
38
35
42
TLE
p03241
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; #define int long long int mod = 1e9 + 7; signed main() { int n, m; cin >> n >> m; vector<int> yk; for (int i = 1; i <= sqrt(m); i++) { if (m % i == 0) { yk.push_back(i); yk.push_back(m / i); } } sort(yk.begin(), yk.end()); double ch = m / n; int ans = 0; for (int i = 0; yk[i] <= ch; i++) { ans = yk[i]; } cout << ans << endl; }
#include "bits/stdc++.h" using namespace std; #define int long long int mod = 1e9 + 7; signed main() { int n, m; cin >> n >> m; vector<int> yk; for (int i = 1; i <= sqrt(m); i++) { if (m % i == 0) { yk.push_back(i); yk.push_back(m / i); } } sort(yk.begin(), yk.end()); double ch = m / n; int ans = 0; for (int i = 0; yk[i] <= ch && i < yk.size(); i++) { ans = yk[i]; } cout << ans << endl; }
replace
18
19
18
19
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef long long ll; typedef pair<int, int> PII; const ll mod = 1000000007; ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "{"; for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i]; o << "}"; return o; } // head struct edge { int to, cap, rev, cost; }; vector<edge> G[1000]; void add_edge(int from, int to, int cap, int cost = 0) { G[from].push_back(edge{to, cap, (int)G[to].size(), cost}); G[to].push_back(edge{from, 0, (int)G[from].size() - 1, -cost}); } int main() { int N, M; std::cin >> N >> M; int ans = 1; rep(i, 1, M / N + 1) { if (M % i == 0) { ans = i; } } std::cout << ans << '\n'; }
#include <bits/stdc++.h> using namespace std; #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, a, n) for (int i = n - 1; i >= a; i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector<int> VI; typedef long long ll; typedef pair<int, int> PII; const ll mod = 1000000007; ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } template <class T> ostream &operator<<(ostream &o, const vector<T> &v) { o << "{"; for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i]; o << "}"; return o; } // head struct edge { int to, cap, rev, cost; }; vector<edge> G[1000]; void add_edge(int from, int to, int cap, int cost = 0) { G[from].push_back(edge{to, cap, (int)G[to].size(), cost}); G[to].push_back(edge{from, 0, (int)G[from].size() - 1, -cost}); } int main() { int N, M; std::cin >> N >> M; int ans = 1; if (N == 1) { std::cout << M << '\n'; exit(0); } rep(i, 1, M / N + 1) { if (M % i == 0) { ans = i; } } std::cout << ans << '\n'; }
insert
47
47
47
51
TLE
p03241
C++
Time Limit Exceeded
#include <cstdio> int main() { int n, M, ans = 1; scanf("%d%d", &n, &M); for (int i = 2; i <= M / n; ++i) { if (M % i) continue; if (M / i >= n) ans = i; } printf("%d", ans); return 0; }
#include <cstdio> int main() { int n, M, ans = 1; scanf("%d%d", &n, &M); if (n == 1) return !printf("%d", M); for (int i = 2; i <= M / n; ++i) { if (M % i) continue; if (M / i >= n) ans = i; } printf("%d", ans); return 0; }
insert
4
4
4
6
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; int ans = 1, tmp; for (int i = 2; i <= M / N; i++) { tmp = M - i * (N - 1); if (tmp % i == 0) ans = i; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; if (N == 1) { cout << M << endl; return 0; } int ans = 1, tmp; for (int i = 2; i <= M / N; i++) { tmp = M - i * (N - 1); if (tmp % i == 0) ans = i; } cout << ans << endl; }
insert
6
6
6
10
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; ++i) #define REPP(i, n) for (int i = 1; i <= n; ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define ALL(v) v.begin(), v.end() #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1000000007; const ll INF = 1000000000; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } ll gcd(ll x, ll y) { if (x < y) gcd(y, x); while (y > 0) { ll tmp = x % y; x = y; y = tmp; } return x; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; ll a = m / 2 + (m % 2), b = m / 2; ll ans = 0; while (ans == 0) { if (a % b == 0) ans = b; a += n - 1; --b; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; ++i) #define REPP(i, n) for (int i = 1; i <= n; ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define ALL(v) v.begin(), v.end() #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll MOD = 1000000007; const ll INF = 1000000000; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } ll gcd(ll x, ll y) { if (x < y) gcd(y, x); while (y > 0) { ll tmp = x % y; x = y; y = tmp; } return x; } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n, m; cin >> n >> m; ll a = m / n + m % n, b = m / n; ll ans = 0; while (ans == 0) { if (a % b == 0) ans = b; a += n - 1; --b; } cout << ans << endl; return 0; }
replace
38
39
38
39
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <iostream> #include <string> #include <utility> // pair #include <vector> #define MAX_N 100001 using namespace std; using ll = long long; using P = pair<ll, ll>; #define FOR(i, a, b) for (ll i = a; i < b; i++) #define REP(i, n) for (ll i = 0; i < n; i++) #define REV(i, n) for (ll i = n - 1; i >= 0; i--) #define ALL(v) v.begin(), v.end() #define pb push_back const ll INF = 9e18; ll n, m; signed main() { cin >> n >> m; ll ret = 0; FOR(i, 1, m / n + 1) { if ((m - i * (n - 1)) % i == 0) ret = max(ret, i); } cout << ret << endl; return 0; }
#include <bits/stdc++.h> #include <iostream> #include <string> #include <utility> // pair #include <vector> #define MAX_N 100001 using namespace std; using ll = long long; using P = pair<ll, ll>; #define FOR(i, a, b) for (ll i = a; i < b; i++) #define REP(i, n) for (ll i = 0; i < n; i++) #define REV(i, n) for (ll i = n - 1; i >= 0; i--) #define ALL(v) v.begin(), v.end() #define pb push_back const ll INF = 9e18; ll n, m; signed main() { cin >> n >> m; ll ret = 0; // FOR(i, 1, m/n + 1){ for (ll i = 1; i * i <= m; i++) { if (m - i * (n - 1) > 0) { if ((m - i * (n - 1)) % i == 0) ret = max(ret, i); } if (m - (m / i) * (n - 1) > 0) { if ((m - (m / i) * (n - 1)) % (m / i) == 0) ret = max(ret, (m / i)); } } cout << ret << endl; return 0; }
replace
20
23
20
30
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <string> using namespace std; typedef long long ll; /*sortの仕方 * ■ string s の場合 * 昇順: sort(s.begin(), s.end()) * 降順: sort(s.rbegin(), s.rend()) * * ■ int a[N] の場合 * 昇順: sort(a, a+N) * 降順: 不明 */ /*int alph2int(char character) { int x = character - 'a'; return x; } */ int main() { int N, M; cin >> N >> M; int ans = 0; for (int i = 1; i <= M; i++) { if (M % i == 0) { if (N <= M / i) { ans = i; } } } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <string> using namespace std; typedef long long ll; /*sortの仕方 * ■ string s の場合 * 昇順: sort(s.begin(), s.end()) * 降順: sort(s.rbegin(), s.rend()) * * ■ int a[N] の場合 * 昇順: sort(a, a+N) * 降順: 不明 */ /*int alph2int(char character) { int x = character - 'a'; return x; } */ int main() { int N, M; cin >> N >> M; int ans = 0; if (N == 1) { cout << M << endl; return 0; } for (int i = 1; i <= M / 2; i++) { if (M % i == 0) { if (N <= M / i) { ans = i; } } } cout << ans << endl; return 0; }
replace
26
27
26
32
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define INF 100100100 #define MOD 1000000007 #define FOR(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; using ull = unsigned long long; struct edge { ll to, cost; }; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(0); ll N, M; cin >> N >> M; ll ans = 1; for (ll i = 1; i <= M / N; i++) { if (M % i == 0 && M / i >= N) ans = i; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define INF 100100100 #define MOD 1000000007 #define FOR(i, n) for (int i = 0; i < n; i++) using namespace std; using ll = long long; using ull = unsigned long long; struct edge { ll to, cost; }; int main(int argc, char const *argv[]) { ios::sync_with_stdio(false); cin.tie(0); ll N, M; cin >> N >> M; ll ans = 1; ll B; for (ll i = 1; i * i <= M; i++) { B = M / i; if (M % i == 0) { if (i <= M / N) ans = max(ans, i); if (B <= M / N) ans = max(ans, B); } } cout << ans << endl; return 0; }
replace
21
24
21
30
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { int N, M; cin >> N >> M; int A = 1; int ans = 0; while (M > (N - 1) * A) { if ((M + A - N * A) % A == 0) ans = A; A++; } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; int main() { int N, M; cin >> N >> M; int A = 1; int ans = 0; if (N == 1) { cout << M << endl; return 0; } while (M > (N - 1) * A) { if ((M + A - N * A) % A == 0) ans = A; A++; } cout << ans << endl; }
insert
10
10
10
14
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, start, end) for (int i = start; i <= end; i++) const int INF = 1001001001; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) typedef long long ll; const ll MOD = 1000000007; using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> auto MAX(const T &a) { return *max_element(a.begin(), a.end()); } template <class T> auto MIN(const T &a) { return *min_element(a.begin(), a.end()); } template <class T, class U> U SUM(const T &a, const U &v) { return accumulate(a.begin(), a.end(), v); } template <class T, class U> U COUNT(const T &a, const U &v) { return count(a.begin(), a.end(), v); } template <class T, class U> int LOWER(const T &a, const U &v) { return lower_bound(a.begin(), a.end(), v) - a.begin(); } template <class T, class U> int UPPER(const T &a, const U &v) { return upper_bound(a.begin(), a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } //--------------------------------------------------------------------------------------------------- template <int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) {} ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template <int MOD> ostream &operator<<(ostream &st, const ModInt<MOD> a) { st << a.get(); return st; }; template <int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } template <typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac; Comb() { fac.resize(FAC_MAX, 1); ifac.resize(FAC_MAX, 1); FOR(i, 1, FAC_MAX - 1) fac[i] = fac[i - 1] * i; ifac[FAC_MAX - 1] = T(1) / fac[FAC_MAX - 1]; for (int i = FAC_MAX - 2; i >= 1; i--) ifac[i] = ifac[i + 1] * T(i + 1); } T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; } T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; } T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0; return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator T pairCombination(int n) { if (n % 2 == 1) return T(0); return fac[n] * ifac[n / 2] / (T(2) ^ (n / 2)); } // combination of paris for n }; typedef ModInt<1000000007> mint; int main(void) { // Your code here! int n, m; cin >> n >> m; int k; FOR(i, 1, m) { if (m % i == 0 && m / i >= n) k = i; } cout << k << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, start, end) for (int i = start; i <= end; i++) const int INF = 1001001001; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) typedef long long ll; const ll MOD = 1000000007; using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> auto MAX(const T &a) { return *max_element(a.begin(), a.end()); } template <class T> auto MIN(const T &a) { return *min_element(a.begin(), a.end()); } template <class T, class U> U SUM(const T &a, const U &v) { return accumulate(a.begin(), a.end(), v); } template <class T, class U> U COUNT(const T &a, const U &v) { return count(a.begin(), a.end(), v); } template <class T, class U> int LOWER(const T &a, const U &v) { return lower_bound(a.begin(), a.end(), v) - a.begin(); } template <class T, class U> int UPPER(const T &a, const U &v) { return upper_bound(a.begin(), a.end(), v) - a.begin(); } int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; } //--------------------------------------------------------------------------------------------------- template <int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) {} ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; template <int MOD> ostream &operator<<(ostream &st, const ModInt<MOD> a) { st << a.get(); return st; }; template <int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) { ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; } template <typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac; Comb() { fac.resize(FAC_MAX, 1); ifac.resize(FAC_MAX, 1); FOR(i, 1, FAC_MAX - 1) fac[i] = fac[i - 1] * i; ifac[FAC_MAX - 1] = T(1) / fac[FAC_MAX - 1]; for (int i = FAC_MAX - 2; i >= 1; i--) ifac[i] = ifac[i + 1] * T(i + 1); } T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; } T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; } T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0; return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator T pairCombination(int n) { if (n % 2 == 1) return T(0); return fac[n] * ifac[n / 2] / (T(2) ^ (n / 2)); } // combination of paris for n }; typedef ModInt<1000000007> mint; int main(void) { // Your code here! int n, m; cin >> n >> m; int k = 0; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { if (m / i >= n) k = max(k, i); if (i >= n) k = max(k, m / i); } } cout << k << endl; }
replace
148
152
148
156
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n, m; cin >> n >> m; int ans = 1; for (int i = 1; i * n <= m; i++) { if ((m - i * n) % i == 0) ans = i; } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n, m; cin >> n >> m; int ans = 1; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { if (i <= m / n) ans = max(ans, i); if (i >= n) ans = max(ans, m / i); } } cout << ans << endl; return 0; }
replace
12
15
12
19
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = M; i >= 1; --i) { if (M % i == 0) { int k = M / i; if (k >= N) { cout << M / k << endl; return 0; } } } }
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = M / N + 1; i >= 1; --i) { if (M % i == 0) { int k = M / i; if (k >= N) { cout << M / k << endl; return 0; } } } }
replace
8
9
8
9
TLE
p03241
C++
Time Limit Exceeded
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <tuple> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; int dy4[4] = {-1, 0, +1, 0}; int dx4[4] = {0, +1, 0, -1}; int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const long long INF = 1LL << 60; const ll MOD = 1e9 + 7; bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) { return f.second > s.second; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll nCr(ll n, ll r) { if (r == 0 || r == n) { return 1; } else if (r == 1) { return n; } return (nCr(n - 1, r) + nCr(n - 1, r - 1)); } ll nPr(ll n, ll r) { r = n - r; ll ret = 1; for (ll i = n; i >= r + 1; i--) ret *= i; return ret; } //-----------------------ここから----------- int main(void) { int n, m; cin >> n >> m; int ans = 1; for (int i = 2; i * n <= m; i++) { if (m % i == 0) { ans = i; } } cout << ans << endl; }
/* これを入れて実行 g++ code.cpp ./a.out */ #include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stdio.h> #include <string> #include <tuple> #include <unordered_map> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; int dy4[4] = {-1, 0, +1, 0}; int dx4[4] = {0, +1, 0, -1}; int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; const long long INF = 1LL << 60; const ll MOD = 1e9 + 7; bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) { return f.second > s.second; } ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } ll nCr(ll n, ll r) { if (r == 0 || r == n) { return 1; } else if (r == 1) { return n; } return (nCr(n - 1, r) + nCr(n - 1, r - 1)); } ll nPr(ll n, ll r) { r = n - r; ll ret = 1; for (ll i = n; i >= r + 1; i--) ret *= i; return ret; } //-----------------------ここから----------- int main(void) { int n, m; cin >> n >> m; int ans = 1; if (n == 1) { cout << m << endl; return 0; } for (int i = 2; i * n <= m; i++) { if (m % i == 0) { ans = i; } } cout << ans << endl; }
insert
70
70
70
74
TLE
p03241
C++
Runtime Error
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define rep(i, x) for (int i = 0; i < x; i++) #define pb push_back #define mp make_pair typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> Pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<vector<vector<int>>> vvvi; const ll MOD = 1e9 + 7; const int n_max = 1e5 + 10; int main() { ll n, m; cin >> n >> m; priority_queue<ll> pq; rep(i, sqrt(m)) { if (!i) continue; if (m % i == 0) { pq.push(i); pq.push(m / i); } } bool ok = true; ll ans = 0; while (ok) { ll temp = pq.top(); pq.pop(); if (n * temp <= m) { ans = temp; ok = false; } } cout << ans << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cstdio> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; #define rep(i, x) for (int i = 0; i < x; i++) #define pb push_back #define mp make_pair typedef long long ll; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> Pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<vector<vector<int>>> vvvi; const ll MOD = 1e9 + 7; const int n_max = 1e5 + 10; int main() { ll n, m; cin >> n >> m; priority_queue<ll> pq; rep(i, sqrt(m) + 1) { if (!i) continue; if (m % i == 0) { pq.push(i); pq.push(m / i); } } bool ok = true; ll ans = 0; while (ok) { ll temp = pq.top(); pq.pop(); if (n * temp <= m) { ans = temp; ok = false; } } cout << ans << endl; return 0; }
replace
25
26
25
26
0
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n, m) for (ll i = n; i <= m; i++) #define rep3(i, n, m) for (ll i = n; i >= m; i--) #define pb push_back #define eb emplace_back #define ppb pop_back #define mpa make_pair #define fi first #define se second const ll INF = 1e18; inline void chmax(ll &a, ll b) { a = max(a, b); } inline void chmin(ll &a, ll b) { a = min(a, b); } int main() { ll n, m; cin >> n >> m; ll ans = 1; rep2(i, 1, m) { if (m % i == 0 && (m / i) >= n) ans = i; } cout << ans << endl; return 0; }
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> using namespace std; using ll = long long; using P = pair<int, int>; using Graph = vector<vector<int>>; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep2(i, n, m) for (ll i = n; i <= m; i++) #define rep3(i, n, m) for (ll i = n; i >= m; i--) #define pb push_back #define eb emplace_back #define ppb pop_back #define mpa make_pair #define fi first #define se second const ll INF = 1e18; inline void chmax(ll &a, ll b) { a = max(a, b); } inline void chmin(ll &a, ll b) { a = min(a, b); } int main() { ll n, m; cin >> n >> m; ll ans = 1; for (ll i = 1; i * i <= m; i++) { if (m % i == 0) { ll j = m / i; if (j >= n) chmax(ans, i); if (i >= n) chmax(ans, j); } } cout << ans << endl; return 0; }
replace
25
28
25
33
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { long long N, M; cin >> N >> M; long long number = 1; for (int i = M; i > sqrt(M) - 1; i--) { if (M % i == 0) { if (M >= i * N) { number = i; break; } else if (i >= N) number = M / i; } } cout << number << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <vector> using namespace std; int main() { long long N, M; cin >> N >> M; long long number = 1; for (int i = M / N + 1; i >= 1; i--) { if (M % i == 0) { if (M >= i * N) { number = i; break; } else if (i >= N) number = M / i; } } cout << number << endl; }
replace
10
11
10
11
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { long long N, M; cin >> N >> M; while (true) { if (M % N == 0) break; else if (M == N) break; else N++; } cout << M / N << endl; return 0; }
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <set> #include <string> #include <vector> using namespace std; int main() { int N, M; cin >> N >> M; int ans, ansMax, temp; ansMax = M / N; for (ans = ansMax; ans > 0; --ans) { temp = M - ans * (N - 1); if ((temp % ans) == 0) { cout << ans << endl; return 0; } } return 0; } int main_failed() { int N, M; cin >> N >> M; while (true) { if (M % N == 0) break; else if (M == N) break; else N++; } cout << M / N << endl; return 0; }
replace
11
12
11
30
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; while (m % n != 0) n++; cout << m / n << '\n'; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int ans = 0; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { if (n <= i) ans = max(ans, m / i); if (n <= m / i) ans = max(ans, i); } } cout << ans << '\n'; }
replace
6
9
6
16
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; // hamko utils #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define repi(i, a, b) \ for (long long i = (long long)(a); i < (long long)(b); i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define mt make_tuple #define mp make_pair template <class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template <class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>; using ld = long double; using vld = vector<ld>; using vi = vector<int>; using vvi = vector<vi>; vll conv(vi &v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; } inline void input(int &v) { v = 0; char c = 0; int p = 1; while (c < '0' || c > '9') { if (c == '-') p = -1; c = getchar(); } while (c >= '0' && c <= '9') { v = (v << 3) + (v << 1) + c - '0'; c = getchar(); } v *= p; } // これを使うならば、tieとかを消して!! template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, size_t... Is> void print_tuple(basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using s = int[]; (void)s{0, (void(os << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}; } template <class Ch, class Tr, class... Args> auto operator<<(basic_ostream<Ch, Tr> &os, tuple<Args...> const &t) -> basic_ostream<Ch, Tr> & { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; } ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; } vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; } template <typename T> istream &operator>>(istream &i, vector<T> &o) { rep(j, o.size()) i >> o[j]; return i; } template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> unordered_map<T, ll> counter(vector<T> vec) { unordered_map<T, ll> ret; for (auto &&x : vec) ret[x]++; return ret; }; string substr(string s, P x) { return s.substr(x.fi, x.se - x.fi); } void vizGraph(vvll &g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "") << endl; } ofs << "}" << endl; ofs.close(); system(((string) "dot -T png out.dot >" + filename).c_str()); } size_t random_seed; namespace std { using argument_type = P; template <> struct hash<argument_type> { size_t operator()(argument_type const &x) const { size_t seed = random_seed; seed ^= hash<ll>{}(x.fi); seed ^= (hash<ll>{}(x.se) << 1); return seed; } }; }; // namespace std #define ldout fixed << setprecision(40) #define EPS (double)1e-14 #define INF (ll)1e18 #define mo (ll)(1e9 + 7) // end of hamko utils int main() { ll N, M; cin >> N >> M; if (M % N == 0) cout << M / N << endl; else { for (ll i = 1; i <= M - N; ++i) { if (M % (N + i) == 0) { cout << M / (N + i) << endl; break; } } } return 0; }
#include <bits/stdc++.h> #include <sys/time.h> using namespace std; // hamko utils #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define repi(i, a, b) \ for (long long i = (long long)(a); i < (long long)(b); i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define mt make_tuple #define mp make_pair template <class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template <class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>; using ld = long double; using vld = vector<ld>; using vi = vector<int>; using vvi = vector<vi>; vll conv(vi &v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; } inline void input(int &v) { v = 0; char c = 0; int p = 1; while (c < '0' || c > '9') { if (c == '-') p = -1; c = getchar(); } while (c >= '0' && c <= '9') { v = (v << 3) + (v << 1) + c - '0'; c = getchar(); } v *= p; } // これを使うならば、tieとかを消して!! template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; } template <size_t...> struct seq {}; template <size_t N, size_t... Is> struct gen_seq : gen_seq<N - 1, N - 1, Is...> {}; template <size_t... Is> struct gen_seq<0, Is...> : seq<Is...> {}; template <class Ch, class Tr, class Tuple, size_t... Is> void print_tuple(basic_ostream<Ch, Tr> &os, Tuple const &t, seq<Is...>) { using s = int[]; (void)s{0, (void(os << (Is == 0 ? "" : ", ") << get<Is>(t)), 0)...}; } template <class Ch, class Tr, class... Args> auto operator<<(basic_ostream<Ch, Tr> &os, tuple<Args...> const &t) -> basic_ostream<Ch, Tr> & { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; } ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; } template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size() - 1 ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; } template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; } vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; } template <typename T> istream &operator>>(istream &i, vector<T> &o) { rep(j, o.size()) i >> o[j]; return i; } template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " "; } return o; } template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " "; } return o; } template <typename T> unordered_map<T, ll> counter(vector<T> vec) { unordered_map<T, ll> ret; for (auto &&x : vec) ret[x]++; return ret; }; string substr(string s, P x) { return s.substr(x.fi, x.se - x.fi); } void vizGraph(vvll &g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "") << endl; } ofs << "}" << endl; ofs.close(); system(((string) "dot -T png out.dot >" + filename).c_str()); } size_t random_seed; namespace std { using argument_type = P; template <> struct hash<argument_type> { size_t operator()(argument_type const &x) const { size_t seed = random_seed; seed ^= hash<ll>{}(x.fi); seed ^= (hash<ll>{}(x.se) << 1); return seed; } }; }; // namespace std #define ldout fixed << setprecision(40) #define EPS (double)1e-14 #define INF (ll)1e18 #define mo (ll)(1e9 + 7) // end of hamko utils int main() { ll N, M; cin >> N >> M; if (M % N == 0) cout << M / N << endl; else { for (ll i = M / N; i > 0; --i) { if (M % i == 0) { cout << i << endl; break; } } } return 0; }
replace
205
208
205
208
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<string> VS; typedef vector<vector<int>> VVI; typedef vector<vector<ll>> VVL; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound int main() { int N, M; cin >> N >> M; while (M % N) N++; cout << M / N << endl; }
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<string> VS; typedef vector<vector<int>> VVI; typedef vector<vector<ll>> VVL; typedef pair<int, int> PII; typedef pair<ll, ll> PLL; #define rep(i, n) for (int i = 0; i < (n); i++) #define all(a) (a).begin(), (a).end() #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound int main() { int N, M; cin >> N >> M; while (M % N and M / 2 >= N) N++; cout << M / N << endl; }
replace
29
30
29
30
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> // #include <unordered_map> using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPR(i, n) for (int i = n; i > -1; --i) #define ALL(a) (a).begin(), (a).end() #define FILL(a, x) \ ; \ REP(i, sizeof(a)) { (a)[i] = (x); } #define CINA(a, n) \ ; \ REP(i, (n)) { cin >> (a)[i]; } #define FILL2(a, n, m, x) \ ; \ REP(i, (n)) { \ REP(j, (m)) { (a)[i][j] = (x); } \ } #define CINA2(a, n, m) \ ; \ REP(i, (n)) { \ REP(j, (m)) { cin >> (a)[i][j]; } \ } #define Liny "Yes\n" #define Linn "No\n" #define LINY "YES\n" #define LINN "NO\n" #define umap unordered_map // cout << setfill('0') << right << setw(4) << 12; // "0012" int keta(ll x) { if (x < 10) { return 1; } else { return keta(x / 10) + 1; } } int keta_wa(ll x) { if (x < 10) { return x; } else { return keta_wa(x / 10) + x % 10; } } int ctoi(char c) { return ((c >= '0' && c <= '9') ? c - '0' : 0); } int __stoi(string s) { return atoi(s.c_str()); } ll sum(ll a[], ll N) { return accumulate(a, a + N, 0LL); } ll gcd(ll a, ll b) { if (a < b) swap(a, b); return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { if (a < b) { swap(a, b); } return a / gcd(a, b) * b; } int main() { ll N, M; cin >> N >> M; ll ans = 1; for (ll i = 2; i <= M / N + 1; ++i) { if (M % i == 0 && M / i >= N) { ans = i; } } cout << ans << "\n"; }
#include <algorithm> #include <cassert> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <memory> #include <numeric> #include <queue> #include <stack> #include <string> #include <vector> // #include <unordered_map> using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define REPR(i, n) for (int i = n; i > -1; --i) #define ALL(a) (a).begin(), (a).end() #define FILL(a, x) \ ; \ REP(i, sizeof(a)) { (a)[i] = (x); } #define CINA(a, n) \ ; \ REP(i, (n)) { cin >> (a)[i]; } #define FILL2(a, n, m, x) \ ; \ REP(i, (n)) { \ REP(j, (m)) { (a)[i][j] = (x); } \ } #define CINA2(a, n, m) \ ; \ REP(i, (n)) { \ REP(j, (m)) { cin >> (a)[i][j]; } \ } #define Liny "Yes\n" #define Linn "No\n" #define LINY "YES\n" #define LINN "NO\n" #define umap unordered_map // cout << setfill('0') << right << setw(4) << 12; // "0012" int keta(ll x) { if (x < 10) { return 1; } else { return keta(x / 10) + 1; } } int keta_wa(ll x) { if (x < 10) { return x; } else { return keta_wa(x / 10) + x % 10; } } int ctoi(char c) { return ((c >= '0' && c <= '9') ? c - '0' : 0); } int __stoi(string s) { return atoi(s.c_str()); } ll sum(ll a[], ll N) { return accumulate(a, a + N, 0LL); } ll gcd(ll a, ll b) { if (a < b) swap(a, b); return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { if (a < b) { swap(a, b); } return a / gcd(a, b) * b; } int main() { ll N, M; cin >> N >> M; ll ans; for (ll i = 1; i <= sqrt(M); ++i) { if (M % i == 0) { if (i >= N) { ans = M / i; break; } if (i <= M / N) { ans = i; } } } cout << ans << "\n"; }
replace
77
81
77
87
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define int64 long long using namespace std; int main() { int n, m, ans; cin >> n >> m; rep1(i, (m / n) + 1) { if (m % i == 0) { ans = i; } } cout << ans << endl; }
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n; i++) #define int64 long long using namespace std; int main() { int n, m, ans; cin >> n >> m; if (n == 1) { ans = m; } else { rep1(i, (m / n) + 1) { if (m % i == 0) { ans = i; } } } cout << ans << endl; }
replace
14
17
14
21
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, m, sum, ans = 1; cin >> n >> m; for (ll i = 1; n * i <= m; i++) { sum = m - n * i; if (sum % i == 0) { ans = i; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, m, sum, ans = 1; cin >> n >> m; ll l = 1, r = 1000000001LL, mid; while (r - l > 1) { mid = (l + r) / 2; if (mid * n <= m) { l = mid; } else { r = mid; } } while (l > 0) { sum = m - n * l; if (sum % l == 0) { ans = l; break; } else { l--; } } cout << ans << endl; return 0; }
replace
6
10
6
22
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; using ll = long long; // graph const ll MAX_V = 1; const ll MAX_E = 1; struct edge { ll from, to, cost; }; edge ES[MAX_E]; vector<edge> G[MAX_V]; ll d[MAX_V]; ll prev_path[MAX_V]; ll V, E; const ll MOD = (ll)1e9 + 7; const int MAX_INT = 1 << 17; vector<bool> prime; #define all(x) (x).begin(), (x).end() #define PRI(n) cout << n << endl; #define PRI2(n, m) cout << n << " " << m << " " << endl; #define REP(i, n) for (int i = 0; i < (ll)n; ++i) #define REPbit(bit, n) for (int bit = 0; bit < (int)(1 << n); ++bit) #define FOR(i, t, n) for (ll i = t; i <= (ll)n; ++i) void Era(int x) { prime.resize(x + 1, 1); prime[0] = 0; prime[1] = 0; FOR(i, 2, sqrt(x)) { if (prime[i]) { for (int j = 2 * i; j <= x; j += i) { prime[j] = 0; } } } } bool isPrime(ll x) { if (x == 0) return 0; if (x == 1) return 0; if (x == 2) return 1; if (x % 2 == 0) return 0; FOR(i, 3, sqrt(x) + 1) { if (x % i == 0) return 0; } return 1; } ll GCD(ll a, ll b) { if (b == 0) return a; return GCD(b, a % b); } ll LCM(ll a, ll b) { ll gcd = GCD(a, b); return a / gcd * b; } ll nCr(ll n, ll r) { vector<ll> C(r + 1); C[0] = 1; FOR(i, 1, n) for (ll j = min(i, r); j < 1; --j) C[j] = (C[j] + C[j - 1]); return C[r]; } template <class T> class SegTree { int n; vector<T> data; T def; function<T(T, T)> operation; function<T(T, T)> update; T _query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; if (a <= l && r <= b) return data[k]; else { T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); return operation(c1, c2); } } public: SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } data = vector<T>(2 * n - 1, def); } void change(int i, T x) { i += n - 1; data[i] = update(data[i], x); while (i > 0) { i = (i - 1) / 2; data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]); } } T query(int a, int b) { return _query(a, b, 0, 0, n); } T operator[](int i) { return data[i + n - 1]; } }; struct UnionFind { vector<int> par; vector<int> rank; UnionFind(int N) { for (int i = 0; i < N; ++i) { par.push_back(i); rank.push_back(0); } } int find(int x) { if (par[x] == x) return x; else return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) par[x] = y; else { par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y) { return find(x) == find(y); } }; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; void Bellman_short(int s) { REP(i, V) d[i] = 1LL << 50; d[s] = 0; REP(i, V) REP(i, E) { edge e = ES[i]; if (d[e.from] != 1LL << 50 && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; } } } bool Bellman_negLoop(int s) { REP(i, V) d[i] = 1LL << 50; d[s] = 0; REP(i, V) REP(j, E) { edge e = ES[j]; if (d[e.from] != 1LL << 50 && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; if (i == V - 1) return true; } } return false; } void dijkstra(int s) { typedef pair<ll, ll> P; priority_queue<P, vector<P>, greater<P>> Q; fill(d, d + V, LLONG_MAX); fill(prev_path, prev_path + V, -1); d[s] = 0; Q.push(P(0, s)); while (!Q.empty()) { P p = Q.top(); Q.pop(); ll v = p.second; if (d[v] < p.first) continue; for (edge e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; Q.push(P(d[e.to], e.to)); prev_path[e.to] = v; } } } } vector<ll> getPath(int t) { vector<ll> path; for (; t != -1; t = prev_path[t]) { path.push_back(t); } reverse(all(path)); return path; } // // int A[100001]; // // bool dfs(ll x, int a) { // A[x] = a; // for (edge e : G[x]) { // if (e.cost % 2 == 0) { // if (A[e.to] == -a)return false; // if (A[e.to] == 0 && !dfs(e.to, a))return false; // } else { // if (A[e.to] == a)return false; // if (A[e.to] == 0 && !dfs(e.to, -a))return false; // } // } // return true; //} bool cp(string s) { PRI(s) if (s.size() % 2 == 0) { int n = s.size() / 2; vector<char> c; REP(i, n) { c.push_back(s[i]); } FOR(i, n, s.size() - 1) { if (c[i - n] != s[i]) return false; } return true; } else { int n = s.size() / 2; vector<char> c; REP(i, n) c.push_back(s[i]); FOR(i, n + 1, s.size() - 1) if (c[i - n + 1] != c[i]) return false; return true; } } ll N, K; string s; int main() { cin >> N >> K; ll ans = 0; FOR(i, 1, K) { if (K / i < N) break; if (K % i == 0) ans = max(ans, i); } PRI(ans) return 0; }
#include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <fstream> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string.h> #include <string> #include <vector> using namespace std; using ll = long long; // graph const ll MAX_V = 1; const ll MAX_E = 1; struct edge { ll from, to, cost; }; edge ES[MAX_E]; vector<edge> G[MAX_V]; ll d[MAX_V]; ll prev_path[MAX_V]; ll V, E; const ll MOD = (ll)1e9 + 7; const int MAX_INT = 1 << 17; vector<bool> prime; #define all(x) (x).begin(), (x).end() #define PRI(n) cout << n << endl; #define PRI2(n, m) cout << n << " " << m << " " << endl; #define REP(i, n) for (int i = 0; i < (ll)n; ++i) #define REPbit(bit, n) for (int bit = 0; bit < (int)(1 << n); ++bit) #define FOR(i, t, n) for (ll i = t; i <= (ll)n; ++i) void Era(int x) { prime.resize(x + 1, 1); prime[0] = 0; prime[1] = 0; FOR(i, 2, sqrt(x)) { if (prime[i]) { for (int j = 2 * i; j <= x; j += i) { prime[j] = 0; } } } } bool isPrime(ll x) { if (x == 0) return 0; if (x == 1) return 0; if (x == 2) return 1; if (x % 2 == 0) return 0; FOR(i, 3, sqrt(x) + 1) { if (x % i == 0) return 0; } return 1; } ll GCD(ll a, ll b) { if (b == 0) return a; return GCD(b, a % b); } ll LCM(ll a, ll b) { ll gcd = GCD(a, b); return a / gcd * b; } ll nCr(ll n, ll r) { vector<ll> C(r + 1); C[0] = 1; FOR(i, 1, n) for (ll j = min(i, r); j < 1; --j) C[j] = (C[j] + C[j - 1]); return C[r]; } template <class T> class SegTree { int n; vector<T> data; T def; function<T(T, T)> operation; function<T(T, T)> update; T _query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return def; if (a <= l && r <= b) return data[k]; else { T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); return operation(c1, c2); } } public: SegTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update) : def(_def), operation(_operation), update(_update) { n = 1; while (n < _n) { n *= 2; } data = vector<T>(2 * n - 1, def); } void change(int i, T x) { i += n - 1; data[i] = update(data[i], x); while (i > 0) { i = (i - 1) / 2; data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]); } } T query(int a, int b) { return _query(a, b, 0, 0, n); } T operator[](int i) { return data[i + n - 1]; } }; struct UnionFind { vector<int> par; vector<int> rank; UnionFind(int N) { for (int i = 0; i < N; ++i) { par.push_back(i); rank.push_back(0); } } int find(int x) { if (par[x] == x) return x; else return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rank[x] < rank[y]) par[x] = y; else { par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y) { return find(x) == find(y); } }; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; void Bellman_short(int s) { REP(i, V) d[i] = 1LL << 50; d[s] = 0; REP(i, V) REP(i, E) { edge e = ES[i]; if (d[e.from] != 1LL << 50 && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; } } } bool Bellman_negLoop(int s) { REP(i, V) d[i] = 1LL << 50; d[s] = 0; REP(i, V) REP(j, E) { edge e = ES[j]; if (d[e.from] != 1LL << 50 && d[e.to] > d[e.from] + e.cost) { d[e.to] = d[e.from] + e.cost; if (i == V - 1) return true; } } return false; } void dijkstra(int s) { typedef pair<ll, ll> P; priority_queue<P, vector<P>, greater<P>> Q; fill(d, d + V, LLONG_MAX); fill(prev_path, prev_path + V, -1); d[s] = 0; Q.push(P(0, s)); while (!Q.empty()) { P p = Q.top(); Q.pop(); ll v = p.second; if (d[v] < p.first) continue; for (edge e : G[v]) { if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; Q.push(P(d[e.to], e.to)); prev_path[e.to] = v; } } } } vector<ll> getPath(int t) { vector<ll> path; for (; t != -1; t = prev_path[t]) { path.push_back(t); } reverse(all(path)); return path; } // // int A[100001]; // // bool dfs(ll x, int a) { // A[x] = a; // for (edge e : G[x]) { // if (e.cost % 2 == 0) { // if (A[e.to] == -a)return false; // if (A[e.to] == 0 && !dfs(e.to, a))return false; // } else { // if (A[e.to] == a)return false; // if (A[e.to] == 0 && !dfs(e.to, -a))return false; // } // } // return true; //} bool cp(string s) { PRI(s) if (s.size() % 2 == 0) { int n = s.size() / 2; vector<char> c; REP(i, n) { c.push_back(s[i]); } FOR(i, n, s.size() - 1) { if (c[i - n] != s[i]) return false; } return true; } else { int n = s.size() / 2; vector<char> c; REP(i, n) c.push_back(s[i]); FOR(i, n + 1, s.size() - 1) if (c[i - n + 1] != c[i]) return false; return true; } } ll N, K; string s; int main() { cin >> N >> K; ll ans = 0; if (N == 1) { PRI(K) return 0; } FOR(i, 1, K) { if (K / i < N) break; if (K % i == 0) ans = max(ans, i); } PRI(ans) return 0; }
insert
280
280
280
284
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; typedef unsigned long long ull; using namespace std; #define FALSE printf("false\n"); #define TRUE printf("true\n"); #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < ((int)(n)); ++i) #define pb push_back #define mp make_pair #define fi first #define se second #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); #define test(a) \ cout << "line:" << __LINE__ << "[" << (#a) << ": " << (a) << "]" << endl const int INF = 1e9 + 7; const ll INFL = 9 * 1e18; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; #define SUM(vec) accumulate(all(vec), 0LL) // 配列の中身を全部足す template <typename T> void print(T &&x) { cout << x << endl; } // 改行付き出力 ll inline digit(ll num) { int tmp = 0; while (num) { tmp++; num /= 10; } return tmp; } // 桁数 template <typename T> inline T digitSum(T num) { T sum = 0; while (num) { sum += num % 10; num /= 10; } return sum; } // 各桁の和 template <typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } // 最大公約数 template <typename T> inline T lcm(T a, T b) { T g = gcd(a, b); return a / g * b; } // 最小公倍数 template <typename T> inline T power(T a, T b) { T tmp = 1; rep(i, b) { tmp *= a; } return tmp; } // 累乗 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } bool isPrime(ll n); // 素数か vector<ll> primes(ll n); // 素因数分解 int ctoi(char c) { return c - '0'; } const ll COM_MAX = (ll)(1e6 + 100); // combinationの最大値 vector<ll> fac(COM_MAX), finv(COM_MAX), inv(COM_MAX); void comb_init(); // 初期化 ll comb(ll n, ll k); // nCk template <typename T> bool isOk(int key, T value) { return key <= value.fi; } template <typename T> T binary_search(vector<pair<int, int>> a, T key) { T ok = a.size(); T ng = -1; while (abs(ok - ng) > 1) { T mid = (ok + ng) / 2; if (isOk(key, a[mid])) ok = mid; else ng = mid; } return ok; } // TODO: write int main() { ll n, m; cin >> n >> m; ll tmp = m / n; ll ans = 0; for (int i = 1; i <= (double)m / n; ++i) { if (m % i == 0) ans = i; } print(ans); return 0; } void comb_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < COM_MAX; ++i) { fac[i] = fac[i - 1] * i % INF; inv[i] = INF - inv[INF % i] * (INF / i) % INF; finv[i] = finv[i - 1] * inv[i] % INF; } } ll comb(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % INF) % INF; } bool isPrime(ll n) { for (int i = 2; n >= i * i; ++i) { if (!(n % i)) return false; } return true; } vector<ll> primes(ll n) { vector<ll> v; for (ll i = 2; i * i <= n; ++i) { while (n % i == 0) { n /= i; v.pb(i); } } if (n != 1) v.pb(n); return v; } /* 二分探索の時に使う template<typename T>bool isOk(T key,T value){ return key <= value; } template<typename T>T binary_search(vector<T> a,T key){ T ok = a.size(); T ng = -1; while(abs(ok - ng) > 1){ T mid = (ok + ng) / 2; if(isOk(key,a[mid]))ok = mid; else ng = mid; } return ok; } */
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> typedef long long ll; typedef unsigned long long ull; using namespace std; #define FALSE printf("false\n"); #define TRUE printf("true\n"); #define all(x) (x).begin(), (x).end() #define rep(i, n) for (int i = 0; i < ((int)(n)); ++i) #define pb push_back #define mp make_pair #define fi first #define se second #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()); #define test(a) \ cout << "line:" << __LINE__ << "[" << (#a) << ": " << (a) << "]" << endl const int INF = 1e9 + 7; const ll INFL = 9 * 1e18; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; #define SUM(vec) accumulate(all(vec), 0LL) // 配列の中身を全部足す template <typename T> void print(T &&x) { cout << x << endl; } // 改行付き出力 ll inline digit(ll num) { int tmp = 0; while (num) { tmp++; num /= 10; } return tmp; } // 桁数 template <typename T> inline T digitSum(T num) { T sum = 0; while (num) { sum += num % 10; num /= 10; } return sum; } // 各桁の和 template <typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); } // 最大公約数 template <typename T> inline T lcm(T a, T b) { T g = gcd(a, b); return a / g * b; } // 最小公倍数 template <typename T> inline T power(T a, T b) { T tmp = 1; rep(i, b) { tmp *= a; } return tmp; } // 累乗 template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } bool isPrime(ll n); // 素数か vector<ll> primes(ll n); // 素因数分解 int ctoi(char c) { return c - '0'; } const ll COM_MAX = (ll)(1e6 + 100); // combinationの最大値 vector<ll> fac(COM_MAX), finv(COM_MAX), inv(COM_MAX); void comb_init(); // 初期化 ll comb(ll n, ll k); // nCk template <typename T> bool isOk(int key, T value) { return key <= value.fi; } template <typename T> T binary_search(vector<pair<int, int>> a, T key) { T ok = a.size(); T ng = -1; while (abs(ok - ng) > 1) { T mid = (ok + ng) / 2; if (isOk(key, a[mid])) ok = mid; else ng = mid; } return ok; } // TODO: write int main() { ll n, m; cin >> n >> m; ll tmp = m / n; ll ans = 0; if (n == 1) { print(m); return 0; } for (int i = 1; i <= (double)m / n; ++i) { if (m % i == 0) ans = i; } print(ans); return 0; } void comb_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < COM_MAX; ++i) { fac[i] = fac[i - 1] * i % INF; inv[i] = INF - inv[INF % i] * (INF / i) % INF; finv[i] = finv[i - 1] * inv[i] % INF; } } ll comb(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % INF) % INF; } bool isPrime(ll n) { for (int i = 2; n >= i * i; ++i) { if (!(n % i)) return false; } return true; } vector<ll> primes(ll n) { vector<ll> v; for (ll i = 2; i * i <= n; ++i) { while (n % i == 0) { n /= i; v.pb(i); } } if (n != 1) v.pb(n); return v; } /* 二分探索の時に使う template<typename T>bool isOk(T key,T value){ return key <= value; } template<typename T>T binary_search(vector<T> a,T key){ T ok = a.size(); T ng = -1; while(abs(ok - ng) > 1){ T mid = (ok + ng) / 2; if(isOk(key,a[mid]))ok = mid; else ng = mid; } return ok; } */
insert
110
110
110
114
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; int n, m; int main() { cin >> n >> m; for (int i = n; i <= m; i++) { if (m % i == 0) { cout << m / i << endl; return 0; } } return 0; }
#include <algorithm> #include <iostream> #include <vector> using namespace std; int n, m; int main() { cin >> n >> m; for (int i = n; i <= m; i++) { if (m % i == 0) { cout << m / i << endl; return 0; } else if (i > m / 2) { cout << 1 << endl; return 0; } } return 0; }
insert
11
11
11
14
TLE
p03241
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; while (M % N != 0) N++; cout << M / N << endl; }
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = M / N; i > 0; i--) if (M % i == 0) { cout << i << endl; break; } }
replace
7
10
7
12
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int ans = 1; for (int i = 1; i * i <= m; --i) { if (m % i == 0) { if (m / i >= n) { ans = max(ans, i); } if (m / (m / i) >= n) { ans = max(ans, m / i); } } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int ans = 1; for (int i = 1; i * i <= m; ++i) { if (m % i == 0) { if (m / i >= n) { ans = max(ans, i); } if (m / (m / i) >= n) { ans = max(ans, m / i); } } } cout << ans << endl; }
replace
8
9
8
9
-8
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define codefor \ int test; \ scanf("%d", &test); \ while (test--) #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define LL(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define yn(ans) \ if (ans) \ printf("Yes\n"); \ else \ printf("No\n") #define YN(ans) \ if (ans) \ printf("YES\n"); \ else \ printf("NO\n") #define vector1d(type, name, ...) vector<type> name(__VA_ARGS__) #define vector2d(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define umap unordered_map #define uset unordered_set using namespace std; using ll = long long; const int MOD = 1000000007; // 入力系 void scan(int &a) { scanf("%d", &a); } void scan(long long &a) { scanf("%lld", &a); } template <class T> void scan(T &a) { cin >> a; } template <class T> void scan(vector<T> &vec) { for (auto &&it : vec) scan(it); } void in() {} template <class Head, class... Tail> void in(Head &head, Tail &...tail) { scan(head); in(tail...); } // 出力系 void print(const int &a) { printf("%d", a); } void print(const long long &a) { printf("%lld", a); } void print(const double &a) { printf("%.15lf", a); } template <class T> void print(const T &a) { cout << a; } template <class T> void print(const vector<T> &vec) { if (vec.empty()) return; print(vec[0]); for (auto it = vec.begin(); ++it != vec.end();) { putchar(' '); print(*it); } } void out() { putchar('\n'); } template <class T> void out(const T &t) { print(t); putchar('\n'); } template <class Head, class... Tail> void out(const Head &head, const Tail &...tail) { print(head); putchar(' '); out(tail...); } // デバッグ系 template <class T> void dprint(const T &a) { cerr << a; } template <class T> void dprint(const vector<T> &vec) { if (vec.empty()) return; cerr << vec[0]; for (auto it = vec.begin(); ++it != vec.end();) { cerr << " " << *it; } } void debug() { cerr << endl; } template <class T> void debug(const T &t) { dprint(t); cerr << endl; } template <class Head, class... Tail> void debug(const Head &head, const Tail &...tail) { dprint(head); cerr << " "; debug(tail...); } ll intpow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; a *= a; b /= 2; } return ans; } ll modpow(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; } ll updivide(ll a, ll b) { if (a % b == 0) return a / b; else return (a / b) + 1; } int main() { LL(n, m); int ans = 1; for (ll i = 2; i <= 1000000000; i++) { if (n * i <= m && (m % (n * i) == 0 || (m % (n * i)) % i == 0)) { ans = i; } } out(ans); }
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define codefor \ int test; \ scanf("%d", &test); \ while (test--) #define INT(...) \ int __VA_ARGS__; \ in(__VA_ARGS__) #define LL(...) \ ll __VA_ARGS__; \ in(__VA_ARGS__) #define yn(ans) \ if (ans) \ printf("Yes\n"); \ else \ printf("No\n") #define YN(ans) \ if (ans) \ printf("YES\n"); \ else \ printf("NO\n") #define vector1d(type, name, ...) vector<type> name(__VA_ARGS__) #define vector2d(type, name, h, ...) \ vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define umap unordered_map #define uset unordered_set using namespace std; using ll = long long; const int MOD = 1000000007; // 入力系 void scan(int &a) { scanf("%d", &a); } void scan(long long &a) { scanf("%lld", &a); } template <class T> void scan(T &a) { cin >> a; } template <class T> void scan(vector<T> &vec) { for (auto &&it : vec) scan(it); } void in() {} template <class Head, class... Tail> void in(Head &head, Tail &...tail) { scan(head); in(tail...); } // 出力系 void print(const int &a) { printf("%d", a); } void print(const long long &a) { printf("%lld", a); } void print(const double &a) { printf("%.15lf", a); } template <class T> void print(const T &a) { cout << a; } template <class T> void print(const vector<T> &vec) { if (vec.empty()) return; print(vec[0]); for (auto it = vec.begin(); ++it != vec.end();) { putchar(' '); print(*it); } } void out() { putchar('\n'); } template <class T> void out(const T &t) { print(t); putchar('\n'); } template <class Head, class... Tail> void out(const Head &head, const Tail &...tail) { print(head); putchar(' '); out(tail...); } // デバッグ系 template <class T> void dprint(const T &a) { cerr << a; } template <class T> void dprint(const vector<T> &vec) { if (vec.empty()) return; cerr << vec[0]; for (auto it = vec.begin(); ++it != vec.end();) { cerr << " " << *it; } } void debug() { cerr << endl; } template <class T> void debug(const T &t) { dprint(t); cerr << endl; } template <class Head, class... Tail> void debug(const Head &head, const Tail &...tail) { dprint(head); cerr << " "; debug(tail...); } ll intpow(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) ans *= a; a *= a; b /= 2; } return ans; } ll modpow(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; } ll updivide(ll a, ll b) { if (a % b == 0) return a / b; else return (a / b) + 1; } int main() { LL(n, m); int ans = 1; if (n == 1) { out(m); return 0; } for (ll i = 2; n * i <= m; i++) { if (n * i <= m && (m % (n * i) == 0 || (m % (n * i)) % i == 0)) { ans = i; } } out(ans); }
replace
121
122
121
126
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <math.h> #include <string> #define REP(i, n) for (int i = 0; i < n; i++) #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; #define mod 1000000007 // 1e9+7(prime number) #define INF 1000000000 // 1e9 using namespace std; typedef long long ll; int main() { ll n, m, ans; cin >> n >> m; for (int i = 1; i * n <= m; i++) { if (m % i == 0) ans = i; } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <math.h> #include <string> #define REP(i, n) for (int i = 0; i < n; i++) #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; #define mod 1000000007 // 1e9+7(prime number) #define INF 1000000000 // 1e9 using namespace std; typedef long long ll; int main() { ll n, m, ans; cin >> n >> m; for (ll i = 1; i * i <= m && i * n <= m; i++) { if (m % i == 0) { if ((m / i) * n <= m) { ans = max(ans, m / i); } else { ans = max(ans, i); } } } cout << ans << endl; return 0; }
replace
17
21
17
25
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <stdio.h> #include <string> #include <vector> #define FOR(i, a, b) for (int i = a; i < b; i++) typedef long long ll; using namespace std; const int MOD = 1e9 + 7; ll N, M, ans = 1; int main(void) { cin >> N >> M; FOR(i, 1, M / N + 1) { if (M % i != 0) continue; if (M / i >= N) ans = i; else break; } cout << ans << endl; return 0; }
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <stdio.h> #include <string> #include <vector> #define FOR(i, a, b) for (int i = a; i < b; i++) typedef long long ll; using namespace std; const int MOD = 1e9 + 7; ll N, M, ans = 1; int main(void) { cin >> N >> M; if (N == 1) ans = M; else { FOR(i, 1, M / N + 1) { if (M % i != 0) continue; if (M / i >= N) ans = i; else break; } } cout << ans << endl; return 0; }
replace
16
23
16
27
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; #define vecout(V) \ for (int i = 0; i < V.size(); i++) { \ cout << V[i] << endl; \ } typedef long long ll; vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main(void) { ll n, m; cin >> n >> m; vector<ll> v = divisor(m); int left = 0; int right = v.size(); while (right - left > 1) { int mid = (left + right) / 2; if (v[mid] >= n) right = mid; else left = mid; } cout << m / v[right] << endl; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; #define vecout(V) \ for (int i = 0; i < V.size(); i++) { \ cout << V[i] << endl; \ } typedef long long ll; vector<ll> divisor(ll n) { vector<ll> ret; for (ll i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } int main(void) { ll n, m; cin >> n >> m; vector<ll> v = divisor(m); if (n == 1) { cout << m << endl; return 0; } int left = 0; int right = v.size(); while (right - left > 1) { int mid = (left + right) / 2; if (v[mid] >= n) right = mid; else left = mid; } cout << m / v[right] << endl; }
insert
26
26
26
30
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define MP make_pair #define PB push_back #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for (int i = 0; i < (n); i++) #define REP1(i, n) for (int i = 1; i < (n); i++) #define REP2(i, d, n) for (int i = (d); i < (n); i++) #define RREP(i, n) for (int i = (n); i >= 0; i--) #define CLR(a) memset((a), 0, sizeof(a)) #define MCLR(a) memset((a), -1, sizeof(a)) #define RANGE(x, y, maxX, maxY) \ (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY)) typedef long long LL; typedef unsigned long long ULL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef vector<LL> VLL; typedef pair<int, int> PII; const int INF = 0x3f3f3f3f; const LL INFL = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-9; const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1}; void solve(long long N, long long M) { LL ans = 1LL; for (LL i = 1; i * N <= M; i++) { if ((M - (i * N)) % i == 0) { ans = i; } } cout << ans << endl; } int main() { long long N; scanf("%lld", &N); long long M; scanf("%lld", &M); solve(N, M); return 0; }
#include <bits/stdc++.h> using namespace std; #define MP make_pair #define PB push_back #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for (int i = 0; i < (n); i++) #define REP1(i, n) for (int i = 1; i < (n); i++) #define REP2(i, d, n) for (int i = (d); i < (n); i++) #define RREP(i, n) for (int i = (n); i >= 0; i--) #define CLR(a) memset((a), 0, sizeof(a)) #define MCLR(a) memset((a), -1, sizeof(a)) #define RANGE(x, y, maxX, maxY) \ (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY)) typedef long long LL; typedef unsigned long long ULL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef vector<LL> VLL; typedef pair<int, int> PII; const int INF = 0x3f3f3f3f; const LL INFL = 0x3f3f3f3f3f3f3f3fLL; const double EPS = 1e-9; const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1}; void solve(long long N, long long M) { if (N == 1) { cout << M << endl; return; } LL ans = 1LL; for (LL i = 1; i * N <= M; i++) { if ((M - (i * N)) % i == 0) { ans = i; } } cout << ans << endl; } int main() { long long N; scanf("%lld", &N); long long M; scanf("%lld", &M); solve(N, M); return 0; }
insert
30
30
30
34
TLE
p03241
C++
Time Limit Exceeded
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll N, M; cin >> N >> M; ll ans; for (ll d = M; d > 0; d++) { if (M % d == 0) { if (M / d >= N) { ans = d; cout << ans << endl; return 0; } } } }
#include <iostream> using namespace std; typedef long long ll; int main(void) { ll N, M; cin >> N >> M; ll ans; for (ll d = M / N; d > 0; d--) { if (M % d == 0) { if (M / d >= N) { ans = d; cout << ans << endl; return 0; } } } }
replace
10
11
10
11
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int N, M; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; for (int i = N; i <= M; i++) { if (M % i == 0) { cout << M / i << endl; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int N, M; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; for (int i = N; i <= M; i++) { if (M % i == 0) { cout << M / i << endl; break; } if (i * 2 > M) { cout << 1 << endl; break; } } return 0; }
insert
19
19
19
23
TLE
p03241
C++
Time Limit Exceeded
#include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); int max = 0; for (int i = 1; i <= b / a; i++) { if (b % i == 0 && i >= max) { max = i; } } printf("%d", max); return 0; }
#include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); int max = 0; if (a == 1 && b == 1000000000) { printf("1000000000"); return 0; } for (int i = 1; i <= b / a; i++) { if (b % i == 0 && i >= max) { max = i; } } printf("%d", max); return 0; }
insert
5
5
5
9
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()) typedef long long ll; typedef pair<int, int> P; int main() { int n, m; cin >> n >> m; int ans = 0; for (int k = 1; k <= m / n; k++) { if (m % k) continue; if (m / k >= n) ans = max(k, ans); } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rep1(i, n) for (int i = 1; i < n + 1; i++) #define sort(A) sort(A.begin(), A.end()) #define reverse(A) reverse(A.begin(), A.end()) typedef long long ll; typedef pair<int, int> P; int main() { int n, m; cin >> n >> m; int ans = 0; if (n == 1) { cout << m << endl; return 0; } for (int k = 1; k <= m / n; k++) { if (m % k) continue; if (m / k >= n) ans = max(k, ans); } cout << ans << endl; }
insert
13
13
13
17
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int ans = 0; for (int i = 1; i <= M / N; i++) { if ((M - N * i) % i == 0) ans = i; } cout << ans << endl; }
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int ans = 0; if (N == 1) ans = M; else { for (int i = 1; i <= M / N; i++) { if ((M - N * i) % i == 0) ans = i; } } cout << ans << endl; }
replace
8
11
8
15
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<int> res; for (int i = 2; i * i <= M; ++i) { if (M % i == 0) { res.push_back(i); if (i != M / i) res.push_back(M / i); } } sort(res.begin(), res.end()); auto it = lower_bound(res.begin(), res.end(), N); cout << M / *it << '\n'; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector<int> res; for (int i = 2; i * i <= M; ++i) { if (M % i == 0) { res.push_back(i); if (i != M / i) res.push_back(M / i); } } res.push_back(1); res.push_back(M); sort(res.begin(), res.end()); auto it = lower_bound(res.begin(), res.end(), N); cout << M / *it << '\n'; return 0; }
insert
21
21
21
23
0
p03241
C++
Time Limit Exceeded
#include "algorithm" #include "bitset" #include "cmath" #include "functional" #include "iostream" #include "map" #include "queue" #include "set" #include "stack" #include "string" #include "tuple" #include "unordered_map" #include "vector" #define rep(n) for (int i = 0; i < n; ++i) #define REP(n, i) for (int i = 0; i < n; ++i) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define intinf 1000000000 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" #define mkp make_pair #define mkt make_tuple #define P pair<ll, ll> #define iP pair<int, int> typedef long long ll; using namespace std; int n, m, i, ans; int main() { cin >> n >> m; for (int i = 1; i <= m && i <= m / n; ++i) { if (m % i == 0) ans = i; } cout << ans << endl; return 0; }
#include "algorithm" #include "bitset" #include "cmath" #include "functional" #include "iostream" #include "map" #include "queue" #include "set" #include "stack" #include "string" #include "tuple" #include "unordered_map" #include "vector" #define rep(n) for (int i = 0; i < n; ++i) #define REP(n, i) for (int i = 0; i < n; ++i) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define intinf 1000000000 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" #define mkp make_pair #define mkt make_tuple #define P pair<ll, ll> #define iP pair<int, int> typedef long long ll; using namespace std; int n, m, i, ans; int main() { cin >> n >> m; if (n == 1) { cout << m << endl; return 0; } for (int i = 1; i <= m && i <= m / n; ++i) { if (m % i == 0) ans = i; } cout << ans << endl; return 0; }
insert
32
32
32
36
TLE
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; using P = pair<ll, ll>; const ll mod = 1e9 + 7; #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++) #define REPS(i, n) for (ll(i) = 1; (i) <= (n); (i)++) #define RREP(i, n) for (ll(i) = (n - 1); (i) >= 0; (i)--) #define RREPS(i, n) for (ll(i) = (n); (i) > 0; (i)--) #define pb push_back #define mp make_pair #define F first #define S second #define UNIQUE(v) v.erase(unique(ALL(v)), v.end()); template <class T> inline void chmin(T &a, T b) { if (a > b) { a = b; } } template <class T> inline void chmax(T &a, T b) { if (a < b) { a = b; } } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12); ll N, M; cin >> N >> M; ll gcm = 0; for (ll i = N;; i++) { if (M < i) break; if (M % i == 0) { chmax(gcm, M / i); break; } } cout << gcm << "\n"; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; using P = pair<ll, ll>; const ll mod = 1e9 + 7; #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++) #define REPS(i, n) for (ll(i) = 1; (i) <= (n); (i)++) #define RREP(i, n) for (ll(i) = (n - 1); (i) >= 0; (i)--) #define RREPS(i, n) for (ll(i) = (n); (i) > 0; (i)--) #define pb push_back #define mp make_pair #define F first #define S second #define UNIQUE(v) v.erase(unique(ALL(v)), v.end()); template <class T> inline void chmin(T &a, T b) { if (a > b) { a = b; } } template <class T> inline void chmax(T &a, T b) { if (a < b) { a = b; } } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12); ll N, M; cin >> N >> M; ll gcm = 0; if (N <= 10) { for (ll i = N;; i++) { if (M < i) break; if (M % i == 0) { chmax(gcm, M / i); break; } } } else { for (ll i = 1;; i++) { ll test = M - i * (N - 1); if (test <= 0) break; if (test < i) break; if (test % i == 0) { chmax(gcm, i); } } } cout << gcm << "\n"; }
replace
36
42
36
55
TLE
p03241
C++
Runtime Error
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int ans = (N == 1 ? M : 1); for (int i = 0; i <= M / 2; i++) { if (M % i == 0 && (long long)i * N <= M && ans < i) ans = i; } cout << ans << endl; }
#include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int ans = (N == 1 ? M : 1); for (int i = 2; i <= M / 2; i++) { if (M % i == 0 and (long long) i * N <= M and ans < i) ans = i; } cout << ans << endl; }
replace
8
10
8
10
-8
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long unsigned int ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) int main() { int n, m; scanf("%d %d\n", &n, &m); int max = 1; for (int i = (m / n); i >= 1; i--) { if (m % i == 0) { if (max < i) { max = i; } } } printf("%d\n", max); }
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long unsigned int ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) int main() { int n, m; scanf("%d %d\n", &n, &m); int max = 1; for (int i = (m / n); i >= 1; i--) { if (m % i == 0) { max = i; break; } } printf("%d\n", max); }
replace
28
31
28
31
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i, s, l) for (lli i = s; i < l; i++) #define DEBUG 0 #define INF (1LL << 50) #define MOD 1000000007 vector<lli> divisorList(lli num) { vector<lli> v; for (lli i = 1; i * i <= num; i++) { if (num % i == 0) { v.push_back(i); v.push_back(num / i); } } sort(v.begin(), v.end()); return v; } signed main() { lli n, m; cin >> n >> m; lli ans = 0; vector<lli> v = divisorList(m); for (lli i = 0; i <= v.size(); i++) { if (m / v[i] < n) break; if (m % v[i] == 0) { ans = max(ans, v[i]); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i, s, l) for (lli i = s; i < l; i++) #define DEBUG 0 #define INF (1LL << 50) #define MOD 1000000007 vector<lli> divisorList(lli num) { vector<lli> v; for (lli i = 1; i * i <= num; i++) { if (num % i == 0) { v.push_back(i); v.push_back(num / i); } } sort(v.begin(), v.end()); return v; } signed main() { lli n, m; cin >> n >> m; lli ans = 0; vector<lli> v = divisorList(m); for (lli i = 0; i < v.size(); i++) { if (m / v[i] < n) break; if (m % v[i] == 0) { ans = max(ans, v[i]); } } cout << ans << endl; return 0; }
replace
30
31
30
31
0
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> ii; struct fastio { fastio() { ios::sync_with_stdio(false); cout << setprecision(10) << fixed; cin.tie(0); } }; fastio _fast_io; const int N = 1e5 + 5; int n, m, k, ans; int main() { cin >> n >> m; for (int i = i; i * i <= m; ++i) { if (m % i == 0 && m / i >= n) { ans = max(i, ans); } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> ii; struct fastio { fastio() { ios::sync_with_stdio(false); cout << setprecision(10) << fixed; cin.tie(0); } }; fastio _fast_io; const int N = 1e5 + 5; int n, m, k, ans; int main() { cin >> n >> m; for (int i = 1; i * i <= m; ++i) { if (m % i == 0) { if (m / i >= n) ans = max(i, ans); if (i >= n) ans = max(m / i, ans); } } cout << ans << endl; return 0; }
replace
21
24
21
27
0
p03241
C++
Time Limit Exceeded
#include <cstdio> int main() { int n, m, i; scanf("%d%d", &n, &m); for (i = m; i; i--) if (!(m % i) && m / i >= n) { printf("%d\n", i); return 0; } }
#include <cstdio> int main() { int n, m, i; scanf("%d%d", &n, &m); for (i = m / n; i; i--) if (!(m % i) && m / i >= n) { printf("%d\n", i); return 0; } }
replace
4
5
4
5
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, M, lim; cin >> N >> M; lim = M / N; int num = 0; vector<int> yakusu(M); for (int i = 0; i < sqrt(M); i++) { if (M % (i + 1) == 0) { yakusu[num] = i + 1; num++; yakusu[num] = M / (i + 1); num++; } } int max = -1; for (int i = 0; i < yakusu.size(); i++) { if (yakusu[i] <= lim) { if (max < yakusu[i]) max = yakusu[i]; } } cout << max << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, M, lim; cin >> N >> M; lim = M / N; int num = 0; vector<int> yakusu(1000000); for (int i = 0; i < sqrt(M); i++) { if (M % (i + 1) == 0) { yakusu[num] = i + 1; num++; yakusu[num] = M / (i + 1); num++; } } int max = -1; for (int i = 0; i < yakusu.size(); i++) { if (yakusu[i] <= lim) { if (max < yakusu[i]) max = yakusu[i]; } } cout << max << endl; }
replace
8
9
8
9
0
p03241
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define rep(i, a) for (int i = 0; i < int(a); ++i) #define REP(i, a, b) for (int i = int(a); i < int(b); ++i) using ll = long long; using itn = int; using namespace std; using Graph = vector<vector<int>>; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int main() { int N, M; cin >> N >> M; int ans = 0; if (M % N == 0) cout << M / N << endl; else { for (int i = sqrt(M / N); i <= M / N; i++) { ans = max(ans, GCD(i, M - (N - 1) * i)); } cout << ans << endl; } }
#include <bits/stdc++.h> #define rep(i, a) for (int i = 0; i < int(a); ++i) #define REP(i, a, b) for (int i = int(a); i < int(b); ++i) using ll = long long; using itn = int; using namespace std; using Graph = vector<vector<int>>; int GCD(int a, int b) { return b ? GCD(b, a % b) : a; } int main() { int N, M; cin >> N >> M; int ans = 0; if (M % N == 0) cout << M / N << endl; else { for (int i = 1; i <= M / N; i++) { if (M % i == 0) ans = i; } cout << ans << endl; } }
replace
15
17
15
18
TLE
p03241
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int ans = 1; for (int i = 1; i <= (int)M / N; i++) ans = (M % i == 0) ? i : ans; cout << ans << endl; }
#include <cmath> #include <iostream> using namespace std; int main() { int N, M; cin >> N >> M; int ans = 1; if (N == 1) { cout << M << endl; return 0; } for (int i = 1; i <= (int)M / N; i++) ans = (M % i == 0) ? i : ans; cout << ans << endl; }
insert
10
10
10
15
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long N, M, p = 0; cin >> N >> M; p = M; while (true) { if (M % p == 0 && p * N <= M) { p = p + 10000000; break; } p = p - 10000000; } for (int i = p; i > 0; i--) { if (M % i == 0 && i * N <= M) { cout << i; break; } } }
#include <bits/stdc++.h> using namespace std; int main() { long N, M, p = 0; cin >> N >> M; p = M; while (true) { if (p * N <= M) { p = p + 10000000; break; } p = p - 10000000; } for (int i = p; i > 0; i--) { if (M % i == 0 && i * N <= M) { cout << i; break; } } }
replace
8
9
8
9
TLE
p03241
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define F first #define S second #define PB push_back #define MP make_pair #define what_is(x) cerr << #x << " is " << x << endl; #define MT make_tuple #define eb emplace_back #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define REP(i, a, b) for (int i = a; i <= b; i++) #define FOR(i, n) for (int i = 0; i < n; i++) #define error(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ err(_it, args); \ } void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } clock_t startTime; long double getTime() { return (long double)(clock() - startTime) / CLOCKS_PER_SEC; } int main() { startTime = clock(); ll n, m; cin >> n >> m; std::vector<ll> div; for (ll i = 1; i < sqrt(m) + 1; i++) { if (m % i == 0) div.eb(i); } for (auto x : div) { div.eb(m / x); } ll j = div.size() - 1; while (j >= 0 && div[j] * n > m) j--; cout << div[j]; return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pi; #define F first #define S second #define PB push_back #define MP make_pair #define what_is(x) cerr << #x << " is " << x << endl; #define MT make_tuple #define eb emplace_back #define rep(i, begin, end) \ for (__typeof(end) i = (begin) - ((begin) > (end)); \ i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define REP(i, a, b) for (int i = a; i <= b; i++) #define FOR(i, n) for (int i = 0; i < n; i++) #define error(args...) \ { \ string _s = #args; \ replace(_s.begin(), _s.end(), ',', ' '); \ stringstream _ss(_s); \ istream_iterator<string> _it(_ss); \ err(_it, args); \ } void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } clock_t startTime; long double getTime() { return (long double)(clock() - startTime) / CLOCKS_PER_SEC; } int main() { startTime = clock(); ll n, m; cin >> n >> m; std::vector<ll> div; for (ll i = 1; i < sqrt(m) + 1; i++) { if (m % i == 0) div.eb(i); } for (ll k = div.size() - 1; k >= 0; k--) { div.eb(m / div[k]); } ll j = div.size() - 1; while (j >= 0 && div[j] * n > m) j--; cout << div[j]; return 0; }
replace
49
51
49
51
0
p03241
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, m) for (long long i = 0; i < m; i++) #define per(i, m) for (long long i = m - 1; i >= 0; i--) #define FOR(i, n, m) for (long long i = n; i < m; i++) #define ROF(i, n, m) for (long long i = n - 1; i >= m; i--) #define all(x) (x).begin(), (x).end() #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; using namespace std; typedef long long ll; const ll MOD = 998244353; typedef pair<ll, ll> LP; ll POW(ll m, ll n) { if (n < 0) return 0; if (n == 0) return 1; return m * POW(m, n - 1) % MOD; } ll gcd(ll u, ll v) { ll r; while (0 != v) { r = u % v; u = v; v = r; } return u; } ll KAI(ll m) { if (m < 0) return 0; if (m == 0) return 1; return m * KAI(m - 1) % MOD; } ll extGCD(ll a, ll b, ll &x, ll &y) { if (b == 0) { x = 1; y = 0; return a; } ll d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } inline ll mod(ll a, ll m) { return (a % m + m) % m; } ll modinv(ll a, ll m) { ll x, y; extGCD(a, m, x, y); return mod(x, m); } ll COM(ll m, ll n) { if (m < n) return 0; if (n < 0) return 0; if (n == 0) return 1; if (m == n) return 1; return m % MOD * COM(m - 1, n) % MOD * modinv(m - n, MOD) % MOD; } int main() { ll n, m, k, ans; k = 0; cin >> n >> m; FOR(i, n, n + 100000) if (m % i == 0) { k = 1; printf("%lld", m / i); break; } if (k == 0) { rep(i, 100000) if (m % i == 0 && m / i >= n) ans = i; printf("%lld", ans); } }
#include <bits/stdc++.h> #define rep(i, m) for (long long i = 0; i < m; i++) #define per(i, m) for (long long i = m - 1; i >= 0; i--) #define FOR(i, n, m) for (long long i = n; i < m; i++) #define ROF(i, n, m) for (long long i = n - 1; i >= m; i--) #define all(x) (x).begin(), (x).end() #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) \ cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \ << " " << __FILE__ << endl; using namespace std; typedef long long ll; const ll MOD = 998244353; typedef pair<ll, ll> LP; ll POW(ll m, ll n) { if (n < 0) return 0; if (n == 0) return 1; return m * POW(m, n - 1) % MOD; } ll gcd(ll u, ll v) { ll r; while (0 != v) { r = u % v; u = v; v = r; } return u; } ll KAI(ll m) { if (m < 0) return 0; if (m == 0) return 1; return m * KAI(m - 1) % MOD; } ll extGCD(ll a, ll b, ll &x, ll &y) { if (b == 0) { x = 1; y = 0; return a; } ll d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } inline ll mod(ll a, ll m) { return (a % m + m) % m; } ll modinv(ll a, ll m) { ll x, y; extGCD(a, m, x, y); return mod(x, m); } ll COM(ll m, ll n) { if (m < n) return 0; if (n < 0) return 0; if (n == 0) return 1; if (m == n) return 1; return m % MOD * COM(m - 1, n) % MOD * modinv(m - n, MOD) % MOD; } int main() { ll n, m, k, ans; k = 0; cin >> n >> m; FOR(i, n, n + 100000) if (m % i == 0) { k = 1; printf("%lld", m / i); break; } if (k == 0) { FOR(i, 1, 100000) if (m % i == 0 && m / i >= n) ans = i; printf("%lld", ans); } }
replace
85
86
85
86
0
p03241
C++
Time Limit Exceeded
// // abc112d.cpp // // // Created by Yoshida Satoshi on 2018/10/22. // #include <iostream> #include <stdio.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = N; i <= M; i++) { if (M % i == 0) { cout << M / i << endl; break; } } return 0; }
// // abc112d.cpp // // // Created by Yoshida Satoshi on 2018/10/22. // #include <iostream> #include <stdio.h> using namespace std; int main() { int N, M; cin >> N >> M; for (int i = N; i <= M; i++) { if (M % i == 0) { cout << M / i << endl; break; } if (i > M / 2) { cout << 1 << endl; break; } } return 0; }
insert
22
22
22
26
TLE
p03241
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; #define REP(i, limit) for (int i = 0; i < limit; ++i) #define LINT long long int main() { int N, M; cin >> N >> M; int k = M / N; int ans = 1; int work; for (int i = 2; i < k + 1; ++i) { if ((M - N * i) % i == 0) ans = i; } cout << ans << endl; return 0; }
#include <algorithm> #include <iostream> #include <queue> #include <string> #include <vector> using namespace std; #define REP(i, limit) for (int i = 0; i < limit; ++i) #define LINT long long int main() { int N, M; cin >> N >> M; int k = M / N; int ans = 1; int work; if (N == 1) { cout << M << endl; return 0; } for (int i = 2; i < k + 1; ++i) { if ((M - N * i) % i == 0) ans = i; } cout << ans << endl; return 0; }
insert
15
15
15
19
TLE
p03241
C++
Runtime Error
/* title: url: */ #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <string> #include <utility> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define INF 1000000007 typedef pair<int, int> pint; typedef long long ll; #define int ll // get vector of prime numbers which is lower than or equal n vector<int> get_primes(int n) { vector<bool> is_prime(n + 1, true); vector<int> res; is_prime[0] = is_prime[1] = false; for (int i = 2; i <= n; i++) { if (is_prime[i]) { res.push_back(i); for (int j = 2 * i; j < is_prime.size(); j = j + i) { is_prime[j] = false; } } } return res; } vector<pair<int, int>> factorize(int n) { vector<pair<int, int>> res; for (int i = 2; i * i <= n; i++) { int tmp = 0; while (n % i == 0) { tmp++; n /= i; } res.push_back(make_pair(i, tmp)); } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } int mpow(int x, int n) { int res = 1; while (n != 0) { if (n & 1) res = res * x % INF; x = x * x % INF; n = n >> 1; } return res; } // mod frac vector<int> mfrac; void set_mfrac(int n) { if (mfrac.size() == 0) { mfrac.push_back(1); } for (int i = mfrac.size(); i <= n; i++) { mfrac.push_back((i * mfrac[i - 1]) % INF); } } // get nCm mod INF int mcomb(int n, int m) { if (mfrac.size() <= n) { set_mfrac(n); } int res = mfrac[n]; res = res * mpow(mfrac[m], INF - 2) % INF; res = res * mpow(mfrac[n - m], INF - 2) % INF; return res; } vector<int> get_gcd(int n) { vector<int> res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { if (i * i == n) { res.push_back(i); } else { res.push_back(i); res.push_back(n / i); } } } return res; } signed main() { int ans = 1; int N, M; cin >> N >> M; auto gcd = get_gcd(M); sort(gcd.begin(), gcd.end()); for (int i = 0; gcd[i] * N <= M; i++) { ans = max(ans, gcd[i]); } cout << ans << endl; }
/* title: url: */ #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <map> #include <queue> #include <string> #include <utility> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define INF 1000000007 typedef pair<int, int> pint; typedef long long ll; #define int ll // get vector of prime numbers which is lower than or equal n vector<int> get_primes(int n) { vector<bool> is_prime(n + 1, true); vector<int> res; is_prime[0] = is_prime[1] = false; for (int i = 2; i <= n; i++) { if (is_prime[i]) { res.push_back(i); for (int j = 2 * i; j < is_prime.size(); j = j + i) { is_prime[j] = false; } } } return res; } vector<pair<int, int>> factorize(int n) { vector<pair<int, int>> res; for (int i = 2; i * i <= n; i++) { int tmp = 0; while (n % i == 0) { tmp++; n /= i; } res.push_back(make_pair(i, tmp)); } if (n != 1) { res.push_back(make_pair(n, 1)); } return res; } int mpow(int x, int n) { int res = 1; while (n != 0) { if (n & 1) res = res * x % INF; x = x * x % INF; n = n >> 1; } return res; } // mod frac vector<int> mfrac; void set_mfrac(int n) { if (mfrac.size() == 0) { mfrac.push_back(1); } for (int i = mfrac.size(); i <= n; i++) { mfrac.push_back((i * mfrac[i - 1]) % INF); } } // get nCm mod INF int mcomb(int n, int m) { if (mfrac.size() <= n) { set_mfrac(n); } int res = mfrac[n]; res = res * mpow(mfrac[m], INF - 2) % INF; res = res * mpow(mfrac[n - m], INF - 2) % INF; return res; } vector<int> get_gcd(int n) { vector<int> res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { if (i * i == n) { res.push_back(i); } else { res.push_back(i); res.push_back(n / i); } } } return res; } signed main() { int ans = 1; int N, M; cin >> N >> M; auto gcd = get_gcd(M); sort(gcd.begin(), gcd.end()); for (int i = 0; gcd[i] * N <= M && i < gcd.size(); i++) { ans = max(ans, gcd[i]); } cout << ans << endl; }
replace
117
118
117
118
0
p03241
C++
Runtime Error
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define Rep(i, a, b) for (int i = a; i < b; i++) #define REP(i, a, b) for (int i = a; i <= b; i++) #define rev(i, n) for (int i = n - 1; i >= 0; i--) #define vi vector<int> #define pb push_back #define pi pair<int, int> #define vp vector<pair<int, int>> #define mp make_pair #define all(v) (v).begin(), (v).end() #define fi first #define se second #define MEMSET(a) memset(a, 0, sizeof(a)) #define inf (1ll << 60) #define Yes(f) cout << (f ? "Yes" : "No") << endl #define yes(f) cout << (f ? "yes" : "no") << endl #define YES(f) cout << (f ? "YES" : "NO") << endl using namespace std; const int mod = 1e9 + 7; void run(); void init() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); } signed main() { init(); run(); return 0; } void run() { int n, m; cin >> n >> m; vi d; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { d.pb(i); d.pb(m / i); } } sort(all(d)); int ans; for (int i = 0; d[i] <= m / n; i++) { ans = d[i]; } cout << ans << endl; }
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define int long long #define rep(i, n) for (int i = 0; i < n; i++) #define Rep(i, a, b) for (int i = a; i < b; i++) #define REP(i, a, b) for (int i = a; i <= b; i++) #define rev(i, n) for (int i = n - 1; i >= 0; i--) #define vi vector<int> #define pb push_back #define pi pair<int, int> #define vp vector<pair<int, int>> #define mp make_pair #define all(v) (v).begin(), (v).end() #define fi first #define se second #define MEMSET(a) memset(a, 0, sizeof(a)) #define inf (1ll << 60) #define Yes(f) cout << (f ? "Yes" : "No") << endl #define yes(f) cout << (f ? "yes" : "no") << endl #define YES(f) cout << (f ? "YES" : "NO") << endl using namespace std; const int mod = 1e9 + 7; void run(); void init() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(12); } signed main() { init(); run(); return 0; } void run() { int n, m; cin >> n >> m; vi d; for (int i = 1; i * i <= m; i++) { if (m % i == 0) { d.pb(i); d.pb(m / i); } } sort(all(d)); int ans = 1; for (int i = 0; i < d.size() && d[i] <= m / n; i++) { ans = d[i]; } cout << ans << endl; }
replace
50
52
50
52
0