Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void foo(long x) {
- if (x < 10) cout << 0;
- if (x < 100) cout << 0;
- if (x < 1000) cout << 0;
- if (x < 10000) cout << 0;
- if (x < 100000) cout << 0;
- }
- int main() {
- long n;
- cin >> n;
- long m;
- cin >> m;
- if (n == 0) {
- foo(1);
- cout << 1;
- exit(0);
- }
- if (n >= m) {
- foo(0);
- cout << 0;
- } else {
- long x = 1;
- for (long i = 1; i <= n; i++) {
- x *= i;
- x %= m;
- }
- foo(x);
- cout << x;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement