Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include "stdio.h"
- #define INF 99999999
- #define E 0.00000001
- int main()
- {
- int n[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, f, l;
- long long in, c;
- scanf("%I64d", &in);
- c = in;
- while (c > 9)
- {
- n[c % 10]++;
- c /= 10;
- }
- f = c;
- l = n[0] + n[1] + n[2] + n[3] + n[4] + n[5] + n[6] + n[7];
- if (l || (n[8] > 1))
- {
- f--;
- n[9] += n[8] + l;
- l = 1;
- in = f;
- while (n[9])
- {
- in *= 10;
- in += 9;
- --n[9];
- }
- }
- printf("%I64d", in);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement