


Codeforces Round #274 (Div. 2) E题:Riding in a Lift(DP)_html/css_WEB-ITnose
Question address: http://codeforces.com/contest/479/problem/E
The dynamic transfer equation of this question is very interesting, but the most obvious one is k*n*n The complexity is obviously not possible. So I thought of using line segment trees to maintain DP information, but only k*n is already on the verge of TLE. . Adding a log will cause TLE, so it won't work. After searching on the Internet, I found that a little trick of using prefix sum can be used. = =! I have used it many times and never thought of it. . . . Poor IQ. . So the rest is simple.
I originally thought that it would be impossible to walk to the other side of b, so I just counted one side. . But I didn’t realize it until I wrote it. . Counting only one side is not as short as counting both sides. . So just forget it.
The code is as follows:
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64const LL mod=1e9+7;LL dp[6000], sum[3][6000];int main(){ LL n, a, b, k, i, j; while(scanf("%I64d%I64d%I64d%I64d",&n,&a,&b,&k)!=EOF) { memset(dp,0,sizeof(dp)); memset(sum,0,sizeof(sum)); dp[a]=1; for(i=a;i<=n;i++) sum[0][i]=1; for(i=1;i<=k;i++) { sum[i&1][0]=0; for(j=1;j<=n;j++) { if(j<b) { dp[j]=(sum[i+1&1][(j+b-1)/2]+mod-dp[j])%mod; } else if(j>b) { dp[j]=(sum[i+1&1][n]+mod-sum[i+1&1][(j+b)/2]+mod-dp[j])%mod; } sum[i&1][j]=(sum[i&1][j-1]+dp[j])%mod; //printf("%I64d ",dp[j]); } //puts(""); } printf("%I64d\n",sum[k&1][n]); } 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











HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

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

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

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 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 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.
