AlexNeagu11

Untitled

Dec 8th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define moduletz 666013
  3. using namespace std;
  4. ifstream in("no_pals.in");
  5. ofstream out("no_pals.out");
  6. int main() {
  7. int n;
  8. int dp[10];
  9. in >> n;
  10. if (n == 1) {
  11. out << "0\n";
  12. return 0;
  13. }
  14. int p = 9;
  15. for (int i = 1; i <= 9; i++) {
  16. dp[i] = 1;
  17. }
  18. out << "0\n";
  19. for (int i = 2; i <= n; i++) {
  20. p = (p * 10) % moduletz;
  21. if (i % 2) {
  22. for (int j = 1; j <= 9; j++) {
  23. dp[j] = (dp[j] * 10) % moduletz;
  24. }
  25. }
  26. int ans = 0;
  27. for (int j = 1; j <= 9; j++) {
  28. ans = (ans + dp[j]) % moduletz;
  29. }
  30. if (p < ans) {
  31. out << p - ans + moduletz << "\n";
  32. continue;
  33. }
  34. out << p - ans << "\n";
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment