-
-
Save hoanbka/e3ccb67c093405cd39ee818ab8cff9d5 to your computer and use it in GitHub Desktop.
Chtholly's request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
string tostr(int n) { | |
stringstream s; | |
string x; | |
while (n > 0) { | |
x += (n % 10 + '0'); | |
n /= 10; | |
} | |
reverse(x.begin(), x.end()); | |
return x; | |
} | |
int main() { | |
string x, y; | |
int p, k; | |
cin >> k >> p; | |
int a = 1; | |
long long ans = 0; | |
while (k--) { | |
x = tostr(a++); | |
y = x; | |
reverse(x.begin(), x.end()); | |
y += x; | |
unsigned long long sum = 0; | |
reverse(y.begin(), y.end()); | |
for (int i = 0; i < y.size(); i++) { | |
sum = (sum * 10) + (y[i] - '0'); | |
} | |
ans = (ans + sum) % p; | |
ans %= p; | |
} | |
cout << ans << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment