当前位置:网站首页>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";
}
边栏推荐
- [groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
- Construction d'un Cluster redis sous Windows
- Invalid bound statement (not found) in idea -- problem solving
- Introduction to RT thread kernel (5) -- memory management
- TPG x AIDU | AI leading talent recruitment plan in progress!
- 2021 electrician cup (the 12th "China Society of electrical engineering Cup" National Undergraduate electrician mathematical modeling) detailed ideas + codes + references
- Official announcement! The third cloud native programming challenge is officially launched!
- Sword finger offer 04 Search in two-dimensional array
- Introduce Hamming distance and calculation examples
- 电源管理总线 (PMBus)
猜你喜欢
SQL set operation
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
Managed service network: application architecture evolution in the cloud native Era
[Business Research Report] top ten trends of science and technology and it in 2022 - with download link
JVM 原理和流程简介
3 minutes learn to create Google account and email detailed tutorial!
windows下Redis-cluster集群搭建
49 pictures and 26 questions explain in detail what is WiFi?
【科普】热设计基础知识:5G光器件之散热分析
概率论与数理统计考试重点复习路线
随机推荐
Scope of package class package
WeNet:面向工业落地的E2E语音识别工具
CSDN body auto generate directory
JMeter -- distributed pressure measurement
[popular science] basic knowledge of thermal design: heat dissipation analysis of 5g optical devices
【acwing】836. Merge sets
Burpsuite grabs app packets
Neural networks and deep learning Chapter 2: machine learning overview reading questions
Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
Download the details and sequence of the original data access from the ENA database in EBI
How to carry out "small step reconstruction"?
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
10 programming habits that web developers should develop
Chapter 6 text processing tools for shell programming (awk)
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
Introduce Hamming distance and calculation examples
How can CIOs use business analysis to build business value?