Guest User

Untitled

a guest
May 6th, 2012
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  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. int main()
  38. {
  39. #ifdef _MSC_VER
  40. freopen("input.txt", "r", stdin);
  41. freopen("output.txt", "w", stdout);
  42. #else
  43. freopen("xxx.in", "r", stdin);
  44. freopen("xxx.out", "w", stdout);
  45. #endif
  46. int ans = 1;
  47. int n;
  48. cin >> n;
  49. int cnt = 0;
  50. for(int i = 5; i <= n; i += 5)
  51. {
  52. int x = i;
  53. while(x%5 == 0)
  54. {
  55. x /= 5;
  56. cnt++;
  57. }
  58. while(cnt && (x&1) == 0)
  59. {
  60. cnt--;
  61. x >>= 1;
  62. }
  63. ans = ans*(x%1000)%1000;
  64. }
  65. for(int i = 1; i <= n; i++)
  66. {
  67. if(i%5 == 0)
  68. continue;
  69. int x = i;
  70. while(cnt && (x&1) == 0)
  71. {
  72. cnt--;
  73. x >>= 1;
  74. }
  75. ans = ans*(x%1000)%1000;
  76. }
  77. if(n >= 7 && ans < 100)
  78. cout << 0;
  79. if(n >= 7 && ans < 10)
  80. cout << 0;
  81. cout << ans;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment