Codeforces Round #226 (Div. 2) C Number Theory_html/css_WEB-ITnose
Title:
The CF machine is really powerful. It only ran for 600ms. It gave you a sequence of n numbers, and then asked m times. Each time you asked, find each number in the sequence. It is to count the multiples of several prime numbers in the interval [a, b], and then sum up the numbers. It is easy to understand after reading the hint below the question, and then I saw that the range of a and b is a bit large, 2*10^ 9. I don’t know how to deal with it, but later I discovered that the maximum number in the sequence is 10^7, so it doesn’t matter how big a and b are. There will be no prime numbers in the sequence that are larger than the maximum number in the sequence. A number is a multiple of it, and then the prime numbers within 10^7 are preprocessed, and the numbers in the sequence are counted. While preprocessing the prime numbers, there is a process of screening out the multiples of the prime numbers, which is here Determine whether the multiple of the prime number is in the sequence. If so, add the number of the number. Finally, find the prefix sum. Then the answer is sum[b] - sum[a - 1],
When screening prime numbers, the second for loop usually starts from 2*i, but there is no guarantee that there is no prime number in the sequence. For example, in the first case, there is 5 in the sequence, then 5 is a multiple of 5. If The second layer of loop will miss a part starting from 2*i. The habitual writing here made me stuck for a while, because the debugging there is not easy to do,
int n;int nnum[10000000 + 55];bool isprime[10000000 + 55];int prime[10000000 + 55];int k;void get_prime() { memset(isprime,false,sizeof(isprime)); for(int i=2;i<10000005 ;i++) { if(!isprime[i]) for(int j=i /*2 * i*/;j<10000005;j+=i) { isprime[j]=true; if(nnum[j])prime[i] += nnum[j]; } } //for(int i=2;i<1000005;i++) // if(!isprime[i]) // prime[k++]=i; for(int i=1;i<10000005;i++) prime[i] += prime[i - 1];}void init() { memset(prime,0,sizeof(prime)); memset(nnum,0,sizeof(nnum));}bool input() { while(cin>>n) { for(int i=0;i<n;i++) { int x; scanf("%d",&x); nnum[x]++; } return false; } return true;}void cal() { get_prime(); int m; scanf("%d",&m); while(m--) { int a,b; scanf("%d %d",&a,&b); a = a>10000000?10000000:a; b = b>10000000?10000000:b; printf("%d\n",prime[b] - prime[a - 1]); }}void output() {}int main() { while(true) { init(); if(input())return 0; cal(); output(); } return 0;}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.
