Beautiful Year

红太狼 2022-08-18 02:24 267阅读 0赞

Beautiful Year

#

Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^

题目描述

It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.
Given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.

输入

There are multiple test cases.
Each test case contains a single line contains integer y (1000 ≤ y ≤ 9000) — the year number.

输出

For each test case:
Print a single integer — the minimum year number that is strictly larger than y and all it’s digits are distinct.
It is guaranteed that the answer exists.

示例输入

  1. 1987
  2. 2013

示例输出

  1. 2013
  2. 2014

提示

来源

qinchuan

示例程序

  • include

    include

    int main()
    {

    1. int i,j,k;
    2. int t,n,m;
    3. int a,b,c,d;
    4. int year,flag;
    5. while(scanf("%d",&year)!=EOF)
    6. {
    7. flag=0;
    8. while(1)
    9. {
    10. year++;
    11. d=year%10;
    12. c=(year/10)%10;
    13. b=(year/100)%10;
    14. a=(year/1000);
    15. if(a!=b&&a!=c&&a!=d&&b!=c&&b!=d&&c!=d)
    16. {
    17. flag=1;
    18. }
    19. if(flag==1)
    20. break;
    21. }
    22. printf("%d\n",year);
    23. }
    24. return 0;

    }

发表评论

表情:
评论列表 (有 0 条评论,267人围观)

还没有评论,来说两句吧...

相关阅读

    相关 New Year, New Me

    新的一年,新的开始 2017年,是我的毕业年,也是我开始参加工作的一年,这一年,很忙碌,很充实,却也很累,但也在一一实现着17年的计划,直到今日,十之八九得到了一个圆满的

    相关 Beautiful Soup

    1. Beautiful Soup的简介 Beautiful Soup 是用Python写的一个HTML/XML的解析器,它可以很好的处理不规范标记并生成剖析树(pars...