-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path556-beautiful-year.cpp
More file actions
87 lines (84 loc) · 1.32 KB
/
Copy path556-beautiful-year.cpp
File metadata and controls
87 lines (84 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* Beautiful Year [271A]
* Problem: https://codeforces.com/problemset/problem/271/A
* Verdict: ACCEPTED Solved: 2020-08-11
* Language: C++17 (GCC 7-32)
* Runtime: 62 ms Memory: 3800 KB
* Tags: brute force
* Author: BidoTeima
* Source: https://codeforces.com/contest/271/submission/89581754
*/
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
class IntsArray
{
private:
int* array_ = nullptr;
size_t size_ = 0;
public:
IntsArray(int n)
{
size_ = static_cast<unsigned>(trunc(log10(n))) + 1;
array_ = new int[size_];
for (size_t i = 0; n; i++)
{
int temp = n % 10;
array_[i] = temp;
n /= 10;
}
}
int toInt()
{
int x = 0;
for (size_t i = 0; i < size_; i++)
{
x *= 10;
x += array_[i];
}
return x;
}
int& operator[](size_t index)
{
return array_[index];
}
int* begin()
{
return &array_[0];
}
int* end()
{
return &array_[size_];
}
size_t size() { return size_; }
};
void test_case()
{
int year;
cin >> year;
while (++year)
{
IntsArray num(year);
bool dist = true;
for (size_t i = 0; i < num.size(); i++)
{
if(find(num.begin()+i+1, num.end(), num[i]) != num.end())
{
dist = false;
break;
}
}
if(dist)
{
cout << year;
break;
}
}
}
int main()
{
test_case();
return 0;
}