Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <stack>
- #include <queue>
- #include <list>
- #include <map>
- #include <set>
- #include <stdlib.h>
- #include <sstream>
- #include <assert.h>
- #include <time.h>
- #pragma comment(linker, "/STACK:20000000")
- #define fr(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
- #define fd(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
- #define mp make_pair
- #define pb push_back
- #define ll long long
- using namespace std;
- int ri(){int x;scanf("%d",&x);return x;}
- ll rll(){ll x;scanf("%lld",&x);return x;}
- void solve()
- {
- ll n;
- cin >> n;
- const ll MAXN=1e7;
- assert(n<=MAXN);
- ll res=1;
- ll x=5;
- ll cnt=0;
- while(x<=n)
- cnt+=n/x,x*=5LL;
- fr(i,2,n)
- {
- x=i;
- while(x%5==0)
- x/=5;
- while(cnt && x%2==0)
- x/=2,cnt--;
- x%=1000;
- res*=x;
- res%=1000;
- }
- res%=1000;
- if (n>=8)
- {
- if (res<10)
- cout << "00";
- else
- if (res<100)
- cout << "0";
- }
- cout << res << endl;
- }
- int main()
- {
- /*#ifndef ONLINE_JUDGE
- freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/input.txt","rt",stdin);
- freopen("C:/Users/CleRIC/Desktop/Универ/acm.timus.ru/output.txt","wt",stdout);
- #else
- //freopen("input.in","rt",stdin);
- //freopen("output.out","wt",stdout);
- #endif*/
- solve();
- /*#ifndef ONLINE_JUDGE
- printf("\n\ntime-%.3lf",clock()*1e-3);
- #endif*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement