From 14b6ca598cdb041b56822fae224134610b7bb345 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Sat, 29 Jul 2023 23:46:41 +0300 Subject: Solved A from the last Div2 --- contests/Round889/B/main | Bin 0 -> 17096 bytes contests/Round889/B/main.cpp | 160 +++++++++++++++++++++++++++++++++++ contests/Round889/B/main.py | 23 +++++ contests/Round889/B/main_input0.txt | 11 +++ contests/Round889/B/main_output0.txt | 10 +++ 5 files changed, 204 insertions(+) create mode 100755 contests/Round889/B/main create mode 100755 contests/Round889/B/main.cpp create mode 100644 contests/Round889/B/main.py create mode 100644 contests/Round889/B/main_input0.txt create mode 100644 contests/Round889/B/main_output0.txt (limited to 'contests/Round889/B') diff --git a/contests/Round889/B/main b/contests/Round889/B/main new file mode 100755 index 0000000..008296e Binary files /dev/null and b/contests/Round889/B/main differ diff --git a/contests/Round889/B/main.cpp b/contests/Round889/B/main.cpp new file mode 100755 index 0000000..86c739a --- /dev/null +++ b/contests/Round889/B/main.cpp @@ -0,0 +1,160 @@ +#include +using namespace std; + +using ll = long long; +using pii = pair; +using vpi = vector; +using vi = vector; +using vll = vector; +using mpii = map; +using mpll = map; +using db = long double; + +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define lb lower_bound +#define ub upper_bound +#define make_unique(x) \ + sort(all((x))); \ + (x).resize(unique(all((x))) - (x).begin()) +#define ceil(a, b) ((a) + (b) - 1) / (b)) + +const int MOD = (int)1e9 + 7; +const db PI = acos((db)-1); +const int dx[4]{1, 0, -1, 0}; +const int dy[4]{0, 1, 0, -1}; + +template +ostream &operator<<(ostream &os, const pair &p); +template ostream &operator<<(ostream &os, const vector &vec); +template +ostream &operator<<(ostream &os, const map &m); +template +ostream &operator<<(ostream &os, const unordered_map &m); +template ostream &operator<<(ostream &os, const set &s); +template +ostream &operator<<(ostream &os, const unordered_set &s); + +template +ostream &operator<<(ostream &os, const pair &p) { + os << "(" << p.first << ", " << p.second << ")"; + return os; +} + +template ostream &operator<<(ostream &os, const vector &vec) { + os << "{"; + for (size_t i = 0; i < vec.size(); ++i) { + if (i > 0) + os << ", "; + os << vec[i]; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_map &m) { + os << "{"; + for (const auto &p : m) { + os << p.first << ": " << p.second << ", "; + } + os << "}"; + return os; +} + +template ostream &operator<<(ostream &os, const set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +template +ostream &operator<<(ostream &os, const unordered_set &s) { + int i = 0; + os << "{"; + for (const auto &e : s) { + if (i > 0) + os << ", "; + os << e; + i++; + } + os << "}"; + return os; +} + +void dbg() { cerr << "\n"; } + +template void dbg(T val, TS... vals) { + cerr << val << " "; + dbg(vals...); +} + +/* stuff you should look for: + --------------------------- + * special cases (n=1?) + * int overflow, array bounds + * do smth instead of nothing and stay organized + * WRITE STUFF DOWN + * DON'T GET STUCK ON ONE APPROACH + */ + +ll factorial(ll n) { + ll ans = 1; + for (ll i = 2; i <= n; i++) { + ans *= i; + } + return ans; +} + +void solve() { + ll n; + cin >> n; + vll v; + int i = 0; + int ans = 0; + for (int i = 0; i < 25; i++) { + v.pb(factorial(i)); + } + dbg(ans); + ll mx = 1; + dbg(v.size()); + for (ll i = 1; i < v.size(); i++) { + for (ll j = i + 1; j < v.size(); j++) { + if (n % (v[j] / v[i - 1]) == 0) { + mx = max(mx, j - i + 1); + dbg("j: ", j, "i: ", i); + dbg(v[j] / v[i]); + } + } + } + dbg("================="); + cout << mx << '\n'; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + solve(); + } +} diff --git a/contests/Round889/B/main.py b/contests/Round889/B/main.py new file mode 100644 index 0000000..3a99f47 --- /dev/null +++ b/contests/Round889/B/main.py @@ -0,0 +1,23 @@ +def factorial(n): + ans = 1 + for i in range(2, n + 1): + ans *= i + return ans + +def solve(): + n = int(input()) + v = [] + for i in range(100): + v.append(factorial(i)) + mx = 1 + for i in range(1, len(v)): + for j in range(i + 1, len(v)): + if n % (v[j] // v[i - 1]) == 0: + print("-> ", j - i + 1) + mx = max(mx, j - i + 1) + print(mx) + +if __name__ == "__main__": + tt = int(input()) + for _ in range(tt): + solve() diff --git a/contests/Round889/B/main_input0.txt b/contests/Round889/B/main_input0.txt new file mode 100644 index 0000000..a603728 --- /dev/null +++ b/contests/Round889/B/main_input0.txt @@ -0,0 +1,11 @@ +10 +1 +40 +990990 +4204474560 +169958913706572972 +365988220345828080 +387701719537826430 +620196883578129853 +864802341280805662 +1000000000000000000 diff --git a/contests/Round889/B/main_output0.txt b/contests/Round889/B/main_output0.txt new file mode 100644 index 0000000..021f75a --- /dev/null +++ b/contests/Round889/B/main_output0.txt @@ -0,0 +1,10 @@ +1 +2 +3 +6 +4 +22 +3 +1 +2 +2 -- cgit v1.2.3