Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define moduletz 666013
- using namespace std;
- ifstream in("no_pals.in");
- ofstream out("no_pals.out");
- int main() {
- int n;
- int dp[10];
- in >> n;
- if (n == 1) {
- out << "0\n";
- return 0;
- }
- int p = 9;
- for (int i = 1; i <= 9; i++) {
- dp[i] = 1;
- }
- out << "0\n";
- for (int i = 2; i <= n; i++) {
- p = (p * 10) % moduletz;
- if (i % 2) {
- for (int j = 1; j <= 9; j++) {
- dp[j] = (dp[j] * 10) % moduletz;
- }
- }
- int ans = 0;
- for (int j = 1; j <= 9; j++) {
- ans = (ans + dp[j]) % moduletz;
- }
- if (p < ans) {
- out << p - ans + moduletz << "\n";
- continue;
- }
- out << p - ans << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment