当前位置:网站首页>775 Div.1 B. integral array mathematics
775 Div.1 B. integral array mathematics
2022-07-05 04:45:00 【Strezia】
B
1800
The question
Give an example containing n n n Sequence of Numbers a 1 , a 2 , . . . , a n a_1,a_2,...,a_n a1,a2,...,an, And give c c c , Indicates that the size of all numbers in the sequence does not exceed c c c. We call a sequence integral if and only if for any two of the sequences ( Or the same ) Count x , y ( x ≤ y ) x,y(x\leq y) x,y(x≤y) , Satisfy ⌊ y x ⌋ \lfloor \frac yx\rfloor ⌊xy⌋ Also in the sequence . Ask whether this sequence is integral . ( n ≤ 1 e 6 ) (n\leq1e6) (n≤1e6)
Ideas
The first reaction of this problem is to use a method similar to prime sieve to optimize , Put right r = ⌊ y x ⌋ r=\lfloor \frac yx\rfloor r=⌊xy⌋ Change your judgment to y y y The judgment of the , It can't be disassembled into x and r x and r x and r ”, So you can enumerate all x x x, And enumerate all r ∉ a r\notin a r∈/a , If in x × r x\times r x×r The corresponding range exists y y y, be r = ⌊ y x ⌋ ∉ a r=\lfloor \frac yx\rfloor\notin a r=⌊xy⌋∈/a , Not whole . The corresponding range is [ r × x , r × x + x − 1 ] [r\times x,r\times x + x - 1] [r×x,r×x+x−1], Whether there is y y y Just preprocess the prefix and .
By harmonic series , Time complexity O ( c log c ) O(c\log c) O(clogc) .
Code
int cnt[maxn], sum[maxn];
void solve() {
int n, c;
cin >> n >> c;
for(int i = 1; i <= c; i++) cnt[i] = 0;
for(int i = 1; i <= n; i++) {
int x;
cin >> x;
cnt[x]++;
}
sum[0] = 0;
for(int i = 1; i <= c; i++) {
sum[i] = sum[i-1] + cnt[i];
}
for(int x = 1; x <= c; x++) {
if(!cnt[y]) {
continue;
}
for(int i = 1; i * x <= c; i++) {
if(cnt[i]) continue;
int l = i * x - 1;
int r = min((i+1)*x-1, c);
if(sum[r] - sum[l]) {
cout << "No\n";
return;
}
}
}
cout << "Yes\n";
}
边栏推荐
- Minor spanning tree
- Burpsuite grabs app packets
- How can CIOs use business analysis to build business value?
- Label exchange experiment
- Interface joint commissioning test script optimization V5.0 (end)
- level17
- Flink集群配置
- Practice | mobile end practice
- 计组笔记(1)——校验码、原补码乘除计算、浮点数计算
- [popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
猜你喜欢

Fonction (sujette aux erreurs)

概率论与数理统计考试重点复习路线

Qt蓝牙:搜索蓝牙设备的类——QBluetoothDeviceDiscoveryAgent

Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...

Matplotlib draws three-dimensional scatter and surface graphs

Cookie learning diary 1

电源管理总线 (PMBus)

【acwing】837. Number of connected block points

次小生成树
![[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)](/img/2b/933586b6feff1d48c5bee11cd734ba.jpg)
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
随机推荐
You Li takes you to talk about C language 7 (define constants and macros)
[popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
OWASP top 10 vulnerability Guide (2021)
2022-2028 global and Chinese equipment as a Service Market Research Report
Solutions and answers for the 2021 Shenzhen cup
Fluent objects and lists
电源管理总线 (PMBus)
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
Official announcement! The third cloud native programming challenge is officially launched!
How should programmers learn mathematics
PHP reads the INI file and writes the modified content
Download the details and sequence of the original data access from the ENA database in EBI
2021 Higher Education Club Cup mathematical modeling national tournament ABCD problem - problem solving ideas
函數(易錯)
Sword finger offer 04 Search in two-dimensional array
level17
A survey of automatic speech recognition (ASR) research
自动语音识别(ASR)研究综述
WeNet:面向工业落地的E2E语音识别工具
[crampon programming] lintcode decoding Encyclopedia - 872 termination process