据说今天是男神SL的生日,但是他很低调,轻轻地送了一道大水题...
就是传说中的 " N !"
4 5
24 120
#include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <map> using namespace std; #define ll long long const int maxn = 5100; ll n, sum; ll qsm(ll a) { ll ans = 1; for(int i = 1; i <= a; i++) { ans = ((ans%2009)*(i%2009))%2009; } return ans; } int main() { while(~scanf("%lld", &n)) { if(n<41) { sum = qsm(n); printf("%lld\n", sum); } else printf("0\n"); } return 0; }
原文:https://www.cnblogs.com/RootVount/p/10994611.html