Codeforces 271A Beautiful Year Solution

Solve in C:

#include<stdio.h>
int main()
{

    int y,a,b,c,d,count=0;
    while(scanf("%d",&y)!=EOF)
    {
        while(y>0)
        {
            y++;
            a=y/1000;
            b=(y%1000)/100;
            c=((y%1000)%100)/10;
            d=((y%1000)%100)%10;

            if(a!=b&&a!=c&&a!=d&&d!=c&&d!=b&&c!=b)
                break;
        }
        printf("%d\n",y);
    }


}

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.