跳到正文

题解

Solution:【LAR-1】LittleAcbg's Round 1

LittleAcbg约 5 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 5 分钟

版本

  1. v1当前

Task A: 【LAR-1】01101

One solution is to use the Polland-Rho method. Check P4718【模板】Pollard-Rho.

Std does not use that method. It uses Sieve of Eratosthenes to find primes that are less than or equal to R\sqrt R. Since R≤105\sqrt R\le10^5, the amount of those primes are actually less than 10410^4 (the actual amount is 95929592).

Then use these primes to test each x∈[L,R]x\in[L,R] if p∣xp|x. The total time would be 104×10510^4\times10^5, which would be able to pass this task.

Task B: 【LAR-1】Abbreviation

Actually this is the template of Trie (even easier than that).

Task C: 【LAR-1】Balanced Tree I

A completely balanced tree would be a complete binary tree. It is easy to use bitwise operations to judge if there exists an integer mm such that n=2m−1n=2^m-1.

Task D: 【LAR-1】Balanced Tree II

It is easy to find out that the minimum height is the minimum integer hh such that 1+3+⋯+3h−1≥n1+3+\dots+3^{h-1}\ge n. One possible construction is to make the sizes of the three sons equal as much as possible.

Task E: 【LAR-1】Desert Explore

An easy interaction. In order to determine the upper left corner of the ancient city, we can go through the first line and go back, go through the second line and go back, …

The operation we printed should be like this:

代码
1 1
DDDD...DAAAA...A S
DDDD...DAAAA...A S
...
DDDD...DAAAA...A (the last line)

The second time we do the opposite:

代码
n m
AAAA...ADDDD...D W
AAAA...ADDDD...D W
...
AAAA...ADDDD...D (the first line)

And it will be easy to calculate (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2).

Task F: 【LAR-1】Finite and Infinite

Just simulate what the task asks you to do. 3232-bit integer type is enough.

Task G: 【LAR-1】Yet Another Mahjong Problem

A searching problem. First find the required tiles. Divide the 1313 tiles into 3+3+3+3+13+3+3+3+1 or 3+3+3+2+23+3+3+2+2 to find a required tile.

Calculate the sum of unused required tiles to get the answer.

原文