Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment(linker,"/STACK:300000000")
- #define _CRT_SECURE_NO_WARNINGS
- #pragma warning(disable:4800)
- #include <iostream>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <cmath>
- #include <map>
- #include <set>
- #include <iomanip>
- #include <memory.h>
- #include <cstdio>
- #include <sstream>
- #include <deque>
- #include <bitset>
- #include <numeric>
- #include <ctime>
- #include <queue>
- #include <hash_map>
- using namespace std;
- #define show(x) cout << #x << " = " << (x) << endl;
- #define fori(i,n) for(int i = 0; i < (n); i++)
- #define forab(i,a,b) for(int i = (a); i <= (b); i++)
- #define sz(v) int((v).size())
- #define all(v) (v).begin(),(v).end()
- const double pi = 3.1415926535897932384626433832795;
- template<class T> T abs(const T &a) { return a >= 0 ? a : -a; };
- template<class T> T sqr(const T &x) { return x * x; }
- typedef pair<int,int> ii;
- typedef long long ll;
- ///////////////////////////////////////
- int main()
- {
- #ifdef _MSC_VER
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #else
- freopen("xxx.in", "r", stdin);
- freopen("xxx.out", "w", stdout);
- #endif
- int ans = 1;
- int n;
- cin >> n;
- int cnt = 0;
- for(int i = 5; i <= n; i += 5)
- {
- int x = i;
- while(x%5 == 0)
- {
- x /= 5;
- cnt++;
- }
- while(cnt && (x&1) == 0)
- {
- cnt--;
- x >>= 1;
- }
- ans = ans*(x%1000)%1000;
- }
- for(int i = 1; i <= n; i++)
- {
- if(i%5 == 0)
- continue;
- int x = i;
- while(cnt && (x&1) == 0)
- {
- cnt--;
- x >>= 1;
- }
- ans = ans*(x%1000)%1000;
- }
- if(n >= 7 && ans < 100)
- cout << 0;
- if(n >= 7 && ans < 10)
- cout << 0;
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment