Codeforces Round #274 (Div. 2) Solution Report_html/css_WEB-ITnose
Question address: http://codeforces.com/contest/479
This time I can only answer 4 questions.
Question A: Expression
Water question.
Just enumerate six situations and find the maximum value.
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 __int64int main(){ LL a, b, c, d[10]; while(scanf("%I64d%I64d%I64d",&a,&b,&c)!=EOF) { d[0]=a*b*c; d[1]=(a+b)*c; d[2]=a+b+c; d[3]=a*(b+c); d[4]=a+b*c; d[5]=a*b+c; sort(d,d+6); printf("%I64d\n",d[5]); } return 0;}
Question B: Towers
Water question.
Every time, one of the largest ones is given to the smallest one, until the difference between the largest one and the smallest one is less than or equal to 1.
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 __int64struct node{ int x, num;}fei[1000];int cmp(node x, node y){ return x.x<y.x;}int a[2000], b[2000];int main(){ int n, m, i, j, cnt, ans; while(scanf("%d%d",&n,&m)!=EOF) { for(i=0;i<n;i++) { scanf("%d",&fei[i].x); fei[i].num=i; } cnt=0; while(m--) { sort(fei,fei+n,cmp); if(fei[n-1].x-fei[0].x<=1) break; a[cnt]=fei[n-1].num; b[cnt++]=fei[0].num; fei[n-1].x--; fei[0].x++; } sort(fei,fei+n,cmp); printf("%d %d\n",fei[n-1].x-fei[0].x, cnt); for(i=0;i<cnt;i++) { printf("%d %d\n",a[i]+1,b[i]+1); } } return 0;}
Question C: Exams
Still water. . Little greedy
Little greedy. First sort them by the marked date, and then scan them. If you can use the smaller ones, give priority to the smaller ones.
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 __int64struct node{ int x, y;}fei[6000];int cmp(node x, node y){ if(x.x==y.x) return x.y<y.y; return x.x<y.x;}int main(){ int n, i, j, ans, k, x1, x2; while(scanf("%d",&n)!=EOF) { for(i=0;i<n;i++) { scanf("%d%d",&fei[i].x,&fei[i].y); } sort(fei,fei+n,cmp); k=1; for(i=0;i<n;i++) { if(fei[i].y>=k) { k=fei[i].y; } else { k=fei[i].x; } } printf("%d\n",k); } return 0;}
Question D:
Still water. . . . Two points.
Consider 4 situations respectively, x, y, x y, y-x. Then use two points to find the difference between these four numbers.
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 __int64int a[110000];int bin_search(int x, int y, int high){ int low=0, mid; while(low<=high) { mid=low+high>>1; if(y-a[mid]==x) return 1; else if(y-a[mid]>x) low=mid+1; else high=mid-1; } return 0;}int main(){ int n, l, x, y, i, j, k, flag1, flag2; while(scanf("%d%d%d%d",&n,&l,&x,&y)!=EOF) { flag1=flag2=0; for(i=0; i<n; i++) { scanf("%d",&a[i]); if(a[i]==x) flag1=1; if(a[i]==y) flag2=1; } if(flag1&&flag2) { printf("0\n"); } else { flag1=flag2=0; for(i=1;i<n;i++) { if(bin_search(x,a[i],i-1)) { flag1=1; break; } } for(i=1;i<n;i++) { if(bin_search(y,a[i],i-1)) { flag2=1; } } if(flag1&&flag2) { printf("0\n"); } else if(flag1) printf("1\n%d\n",y); else if(flag2) printf("1\n%d\n",x); else { int flag=0; for(i=1;i<n;i++) { if(bin_search(y+x,a[i],i-1)) { flag=1; break; } } if(flag) { printf("1\n%d\n",a[i]-x); } else { flag=0; for(i=1;i<n;i++) { if(bin_search(y-x,a[i],i-1)&&(a[i]-y>=0||a[i]+x<=l)) { flag=1; break; } } if(flag&&a[i]-y>=0) { printf("1\n%d\n",a[i]-y); } else if(flag&&a[i]+x<=l) { printf("1\n%d\n",a[i]+x); } else { printf("2\n%d %d\n",x,y); } } } } } 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.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

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.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

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

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...
