Home Web Front-end HTML Tutorial Codeforces Round #262 (Div. 2)-A,B,C,D_html/css_WEB-ITnose

Codeforces Round #262 (Div. 2)-A,B,C,D_html/css_WEB-ITnose

Jun 24, 2016 am 11:59 AM
round

A. Vasya and Socks

No need to say more about the water question, just violent enumeration and that's it.

#include <iostream>#include<stdio.h>#include<stdlib.h>#include<time.h>#include<vector>#include<algorithm>#include<string.h>using namespace std;#define LL __int64int main(){    int n,k;    while(~scanf("%d%d",&n,&k))    {        int m=n;        int ans=n;        int yu=0;        while(m)        {            m=m+yu;            yu=m%k;            m=m/k;            ans+=m;        }        cout<<ans<<endl;    }    return 0;}
Copy after login

B. Little Dima and Equation

Needless to say, it’s a simple question, just enumerate s(x) directly, and then get x, Then it is appropriate to deduce s(x) based on x.

I wrote 81 as 72, and I couldn’t help but feel very sad, sad.

#include <iostream>#include<stdio.h>#include<stdlib.h>#include<time.h>#include<vector>#include<algorithm>#include<string.h>using namespace std;#define LL __int64#define INF 1000000000vector<int>vec;LL pows(LL x,LL y){    LL ans=1;    while(y--)ans=ans*x;    return ans;}int dus(LL x){    int ans=0;    while(x)    {        ans=ans+x%10;        x=x/10;    }    return ans;}int main(){    int n,k;    int a,b,c;    while(~scanf("%d%d%d",&a,&b,&c))    {        LL ans=0;        vec.clear();        for(int i=1;i<=81;i++)        {            ans=(LL)b;            ans=ans*pows(i,a);            ans=ans+(LL)c;            if(ans>=INF)break;            if(ans<=0)continue;            if(dus(ans)==i)vec.push_back(ans);        }        cout<<vec.size()<<endl;        sort(vec.begin(),vec.end());        for(int i=0;i<vec.size();i++)        {            printf("%d",vec[i]);            if(i!=vec.size()-1)printf(" ");            else puts("");        }    }    return 0;}
Copy after login

C. Present

Two points for greed. It is also a form of expression of water problems. . . .

Divide the result into two and be greedy to see if the current result can be achieved.

#include <iostream>#include<stdio.h>#include<stdlib.h>#include<time.h>#include<vector>#include<algorithm>#include<string.h>using namespace std;#define LL __int64#define INF 1000000000#define maxn 220000LL a[maxn];LL b[maxn];LL flag[maxn];LL n,w;LL qiu(LL x){    memset(flag,0,sizeof(flag));    for(LL i=1;i<=n;i++)    {        b[i]=x-a[i];    }    LL ch=0;    LL ans=0;    for(LL i=1;i<=n;i++)    {        ch-=flag[i];        b[i]-=ch;        if(b[i]<0)b[i]=0;        flag[i+w]+=b[i];        ch+=b[i];        ans+=b[i];    }    return ans;}int main(){    LL m;    while(~scanf("%I64d%I64d%I64d",&n,&m,&w))    {        for(LL i=1;i<=n;i++)scanf("%I64d",&a[i]);        LL l=0;        LL r=1e9;        r=r*2;        LL mid=(l+r)/2;        while(l<r)        {            if(qiu(mid)>m)r=mid;            else l=mid+1;            mid=(l+r)/2;        }        mid--;        cout<<mid<<endl;    }    return 0;}
Copy after login

D. Little Victor and Set

It was so tragic when I wrote this question that it turned out to be the last time I thought I could be wrong. The place is written wrong.

I am very sad.

n=r-l 1;

If n<=20, it is obvious that state compression is OK.

If k<=3.

When k=1, it is obvious to take l.

When k=2, it is obvious that taking two adjacent numbers with only the last bit different, their XOR result is 1.

When k=3, the Take l for a number, and then if the result is 0, calculate the minimum value of the remaining two numbers. If the largest of the two numbers

is not greater than r, then we take these three numbers, otherwise we take two numbers so that the result is 1.

When k>=4:

For the alternation of the following two numbers:

..........0111110                     k-2

.....0111111            -1

.....1000000 k

.....1000001 k 1

Obviously we can see The XOR value of k-2,k-1,k,k 1 is 0.

Because n>20, we can definitely find this kind of k.

#include <iostream>#include<stdio.h>#include<stdlib.h>#include<time.h>#include<vector>#include<algorithm>#include<string.h>using namespace std;#define LL __int64#define INF 1000000000#define maxn 220000void dos1(LL l,LL r,LL k){    LL n=r-l+1;    LL st=((LL)1)<<n;    LL ans=0;    LL res=r+100;    LL rst=0;    LL len=0;    for(LL i=1; i<st; i++)    {        ans=0;        len=0;        for(LL j=0; j<n; j++)        {            if(i&(((LL)1)<<j))            {                ans=ans^(j+l);                len++;            }        }        if(len>k)continue;        if(res>ans)        {            res=ans;            rst=i;        }    }    len=0;    for(LL i=0; i<n; i++)    {        if(rst&(((LL)1)<<i))len++;    }    cout<<res<<endl;    cout<<len<<endl;    for(LL i=0; i<n; i++)    {        if(rst&(((LL)1)<<i))        {            len--;            cout<<(i+l);            if(len)cout<<" ";            else cout<<endl;        }    }}LL dos2(LL l,LL r,LL ks){    for(LL i=50; i>=0; i--)    {        if((l&(((LL)1)<<i))!=((r&(((LL)1)<<i))))        {            LL k=((LL)1)<<i;            LL n=(l>>i);            n=(n<<i);            n=n+k;            k=n;            if(k-2>=l&&k+1<=r)            {                return k;            }            else if(k-2<l)return dos2(k,r,ks);            else if(k+1>r)return dos2(l,k-1,ks);        }    }    return 0;}void dos3(LL l,LL r,LL k){    if(k==1)    {        cout<<l<<endl;        cout<<"1"<<endl;        cout<<l<<endl;        return;    }    if(k==2)    {        cout<<"1"<<endl;        cout<<"2"<<endl;        if(l&1)l++;        cout<<l<<" "<<l+1<<endl;        return;    }    LL len=0;    LL n=l;    while(n)    {        len++;        n=n/2;    }    LL a,b;    a=b=0;    int leap=0;    a=b=(((LL)1)<<len);    for(LL i=len; i>=0; i--)    {        if(l&(((LL)1)<<i))        {            if(!leap)b+=(((LL)1)<<i);            else a+=(((LL)1)<<i);            leap++;        }    }    if(b<=r)    {        cout<<"0"<<endl;        cout<<"3"<<endl;        cout<<l<<" "<<a<<" "<<b<<endl;    }    else    {        cout<<"1"<<endl;        cout<<"2"<<endl;        if(l&1)l++;        cout<<l<<" "<<l+1<<endl;    }}int main(){    LL l,r,k;    while(~scanf("%I64d%I64d%I64d",&l,&r,&k))    {        LL n=r-l+1;        if(n<=20)        {            dos1(l,r,k);            continue;        }        if(k<=3)        {            dos3(l,r,k);            continue;        }        LL ans=dos2(l,r,k);        cout<<"0"<<endl;        cout<<"4"<<endl;        for(LL i=ans-2; i<=ans+1; i++)        {            cout<<i;            if(i!=ans+1)cout<<" ";            else cout<<endl;        }    }    return 0;}
Copy after login










Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

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 Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

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.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

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

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

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

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

How to implement adaptive layout of Y-axis position in web annotation? How to implement adaptive layout of Y-axis position in web annotation? Apr 04, 2025 pm 11:30 PM

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

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.

See all articles