codeforces 271A Beautiful Year(暴力水题)
2014-06-05 16:25
375 查看
A. Beautiful Year
点击打开题目
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.
Input
The single line contains integer y
(1000 ≤ y ≤ 9000) — the year number.
Output
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.
Sample test(s)
Input
Output
Input
Output
[/code]
点击打开题目
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
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.
Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.
Input
The single line contains integer y
(1000 ≤ y ≤ 9000) — the year number.
Output
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.
Sample test(s)
Input
1987
Output
2013
Input
2013
Output
2014 ╮(╯▽╰)╭ 被y<=9000,坑了,我这水平不能再水了,加油!!! 代码: [code]#include <iostream> using namespace std; bool check(int n) { int i=0,a[4],j; while(n) { a[i++]=n%10; n/=10; //cout<<a[i-1]<<endl; } for(i=0;i<4;i++) { for(j=i+1;j<4;j++) { if((a[i]==a[j])) return false; } } return true; } int main() { int i,n; while(cin>>n) { for(i=n+1;;i++) { if(check(i)) { cout<<i<<endl; break; } } } return 0; }
[/code]
相关文章推荐
- CodeForces 589I Lottery (暴力,水题)
- codeforces----2017 Hackatari Codeathon(A 暴力搜索 G概率)(水题DEH)
- Codeforces 588B Duff in Love【暴力】水题
- CodeForces 711B Chris and Magic Square (暴力,水题)
- Codeforces-8VC Venture Cup 2016-Elimination Round-626A.暴力 626B.水题 626C.二分
- Codeforces 426 B Sereja and Mirroring【暴力枚举+模拟】水题
- Sereja ans Anagrams - CodeForces 367B 水题
- codeforces 711B B. Chris and Magic Square(水题)
- CodeForces 135B Rectangle and Square(暴力)
- 【CodeForces】455D Serega and Fun 双向链表分块暴力
- codeforces 675B B. Restoring Painting(暴力枚举)
- CodeForces 492B Vanya and Lanterns(水题)
- CodeForces - 908B New Year and Buggy Bot (全排列+暴力)
- Codeforces 609C Load Balancing 【水题】
- Codeforces 626D Jerry's Protest(暴力枚举+概率)
- Codeforces 149A Business trip【水题】
- codeforces 676A A. Nicholas and Permutation(水题)
- codeforces 677A Vanya and Fence(水题)
- CodeForces 614A(水题)
- codeforces 716D. Complete The Graph 堆优化dij+暴力