Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
// Problem: H. Shiori Miyagi and Maximum Array Score // Contest: Codeforces - Codeforces Round 1065 (Div. 3) // URL: https://codeforces.com/contest/2171/problem/H // Memory Limit: 256 MB // Time Limit: 4000 ms // // Powered by CP Editor (https://cpeditor.org) #include
#include
using namespace std; #ifndef __DEBUG__ #define dbg(...) 42 #endif template
using mpq = priority_queue
, greater
>; namespace rngs = std::ranges; using ll = long long; using a2l = array
; using vl = vector
; void solve() { ll n, m; cin >> n >> m; vector
> cache(n + 1); auto dfs = [&](auto &&self, ll id, ll v) -> ll { if (cache[id].count(v)) return cache[id][v]; assert(id >= 2); if (id == 2) return cache[id][v] = std::__lg(v - 1); ll ret = 0; for (ll nv = 1, gain = 0; nv < v; nv *= id, gain += 1) ret = max(ret, self(self, id - 1, nv) + gain); return cache[id][v] = ret; }; auto ans = dfs(dfs, n, m + 1); cout << ans << '\n'; } int main(int argc, char **argv) { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); ll t = 1; cin >> t; while (t--) solve(); return 0; };
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)