Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int MODULE = 1e6;
- struct longNum {
- vector<ll> en;
- longNum(int a){
- while(a != 0){
- en.push_back(a % MODULE);
- a/=MODULE;
- }
- en.push_back(0);
- // cout << en.size()<<" partition\n"; //debug
- }
- void mul (int a){
- int c = 0;
- for(int i = 0; i < en.size(); i++){
- int f = ((ll)en[i] * a + c)% MODULE;
- // cout << en[i] << " current\n"; //debug
- c = (en[i] * a) / MODULE;
- en[i] = f;
- // cout << c << " mod\n"; //debug
- }
- }
- void Write6(ll x) {
- long long M = 1e5;
- while(M > 0) {
- cout << x/M;
- x%=M;
- M/=10;
- }
- }
- void out(){
- if(en[en.size() - 1] != 0){
- cout << en[en.size() - 1];
- for(int i = en.size() - 2; i >= 0; i--){
- Write6(en[i]);
- }
- }
- else{
- cout << en[en.size() - 2];
- for(int i = en.size() - 3; i >= 0; i--){
- Write6(en[i]);
- }
- }
- }
- };
- int main(int argc,char* argv[]) {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- /// ya staralsa ;)
- int a;
- cin >> a;
- longNum num (a);
- for(int i = 2; i < a; i++){
- num.mul(i);
- }
- num.out();
- ///
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement