Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 1.53 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #pragma comment(linker,"/STACK:300000000")
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #pragma warning(disable:4800)
  4.  
  5. #include <iostream>
  6. #include <vector>
  7. #include <string>
  8. #include <algorithm>
  9. #include <cmath>
  10. #include <map>
  11. #include <set>
  12. #include <iomanip>
  13. #include <memory.h>
  14. #include <cstdio>
  15. #include <sstream>
  16. #include <deque>
  17. #include <bitset>
  18. #include <numeric>
  19. #include <ctime>
  20. #include <queue>
  21. #include <hash_map>
  22.  
  23. using namespace std;
  24.  
  25. #define show(x) cout << #x << " = " << (x) << endl;
  26. #define fori(i,n) for(int i = 0; i < (n); i++)
  27. #define forab(i,a,b) for(int i = (a); i <= (b); i++)
  28. #define sz(v) int((v).size())
  29. #define all(v) (v).begin(),(v).end()
  30. const double pi = 3.1415926535897932384626433832795;
  31. template<class T> T abs(const T &a) { return a >= 0 ? a : -a; };
  32. template<class T> T sqr(const T &x) { return x * x; }
  33. typedef pair<int,int> ii;
  34. typedef long long ll;
  35. ///////////////////////////////////////
  36.  
  37.  
  38.  
  39. int main()
  40. {
  41. #ifdef _MSC_VER
  42.  freopen("input.txt", "r", stdin);
  43.  freopen("output.txt", "w", stdout);
  44. #else
  45.  freopen("xxx.in", "r", stdin);
  46.  freopen("xxx.out", "w", stdout);
  47. #endif
  48.         int ans = 1;
  49.         int n;
  50.         cin >> n;
  51.         int cnt = 0;
  52.         for(int i = 5; i <= n; i += 5)
  53.         {
  54.                 int x = i;
  55.                 while(x%5 == 0)
  56.                 {
  57.                         x /= 5;
  58.                         cnt++;
  59.                 }
  60.                 while(cnt && (x&1) == 0)
  61.                 {
  62.                         cnt--;
  63.                         x >>= 1;
  64.                 }
  65.                 ans = ans*x%1000;
  66.         }
  67.         for(int i = 1; i <= n; i++)
  68.         {
  69.                 if(i%5 == 0)
  70.                         continue;
  71.                 int x = i;
  72.                 while(cnt && (x&1) == 0)
  73.                 {
  74.                         cnt--;
  75.                         x >>= 1;
  76.                 }
  77.                 ans = ans*x%1000;
  78.         }
  79.         cout << ans;
  80. }