Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const int maxn = 100 + 100;
- LL sum[maxn];
- bool judge(LL x) {
- int n = 0;
- LL tmp = x;
- while (tmp != 0) {
- sum[n++] = tmp % 10;
- tmp /= 10;
- }
- sum[n] = 0;
- reverse(sum, sum + n + 1);
- for (int i = 1; i <= n; ++i) {
- sum[i] += sum[i - 1];
- }
- for (int i = n + 1; i <= 50; ++i) {
- tmp = sum[i - 1] - sum[i - n - 1];
- if (tmp == x) {
- return true;
- }
- sum[i] = tmp + sum[i - 1];
- }
- return false;
- }
- int main() {
- #ifdef ExRoc
- freopen("test.txt", "r", stdin);
- #endif // ExRoc
- ios::sync_with_stdio(false);
- for (int i = 1; i <= 10000000; ++i) {
- if (judge(i)) {
- cout << i << endl;
- }
- }
- cout << 7913837 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement