Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <list>
- #include <map>
- #include <set>
- #include <numeric>
- #include <algorithm>
- #include <complex>
- #include <limits>
- #include <cmath>
- #include <cstring>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- const long long mod = 1000000007;
- long long n;
- cin >> n;
- if (n == 1)
- {
- cout << 0 << " " << 1 << endl;
- return 0;
- }
- if (n == 2)
- {
- cout << 1 << " " << 1 << endl;
- return 0;
- }
- if (n == 3)
- {
- cout << 1 << " " << 1 << endl;
- return 0;
- }
- if (n == 4)
- {
- cout << 1 << " " << 6 << endl;
- return 0;
- }
- if (n % 2 == 0)
- {
- long long s = (long long)sqrt(n + 1);
- long long r = 1;
- if (s * s == n + 1)
- {
- for (long long i = 2; i <= n; ++i)
- if (i != s)
- r = (r * i) % mod;
- for (long long i = 0; i < n / 2; ++i)
- r = (r * 2) % mod;
- }
- else
- {
- long long p = n / 2;
- for (long long i = 2; i <= n; ++i)
- {
- long long j = i;
- while(j % 2 == 0 && p > 0)
- {
- j /= 2;
- --p;
- }
- r = (r * j) % mod;
- }
- }
- cout << 1 << " " << r << endl;
- return 0;
- }
- long long s = (long long)sqrt((n + 1) / 2);
- if (s * s == (n + 1) / 2)
- {
- long long r = 1;
- for (long long i = 2; i <= n; ++i)
- if (i != s)
- r = (r * i) % mod;
- for (long long i = 0; i < n / 2; ++i)
- r = (r * 2) % mod;
- cout << 1 << " " << r << endl;
- return 0;
- }
- cout << 1 << " " << 1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement