-
-
Save buyoh/ff51d13fe3fda6823671055343fb38d2 to your computer and use it in GitHub Desktop.
tabnotepad
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ver": 0, | |
"date": 1474859492413, | |
"counter": 3, | |
"last": { | |
"data": "\r\n// xのp乗 対数mod\r\n// 逆元...powm(n,E107-2,E107)\r\nll powm(ll x,ll p,ll mod){\r\n ll y=1;\r\n x=x%mod;\r\n while (0<p){\r\n if (p%2==1){\r\n y=(y*x)%mod;\r\n }\r\n x=(x*x)%mod;\r\n p/=2;\r\n }\r\n return y;\r\n}\r\n\r\n// NchooseR のmod版\r\nll choosemod(ll n, ll r,ll mod){\r\n ll i;\r\n ll p=1;\r\n for (i=1;i<=r;i++)\r\n p=(((p*(n-i+1))%mod)*powm(i,mod-2,mod))%mod;\r\n return p;\r\n}\r\n", | |
"directory": "/2", | |
"set": { | |
"type": "plain" | |
} | |
}, | |
"children": [ | |
{ | |
"name": "数え上げ基本@Ruby", | |
"data": "def choose(n,k)\r\n r=1\r\n k.times{|i|\r\n r=r*(n-i)/(i+1)\r\n }\r\n return r\r\nend\r\n\r\ndef perm(x,k);fact(x)/fact(x-k);end\r\n", | |
"set": { | |
"type": "plain" | |
}, | |
"children": [], | |
"id": 0 | |
}, | |
{ | |
"name": "数え上げ@C++", | |
"data": "/*公式\r\nlcm(n,d) * gcd(n,d) = n * d\r\n*/\r\n\r\n// 最大公約数\r\n// __gcd(a,b)\r\n// 最小公倍数\r\n// __lcm(a,b)\r\n\r\ninline int fact(int n){int r=1;for(;1<n;r*=n--);return r;}\r\n\r\nint gcd(int m,int n){\r\n\tif ((0==m) || (0==n))\r\n\t\treturn 0;\r\n\twhile(m!=n){\r\n\t\tif (m>n) m=m-n;\r\n\t\telse n=n-m;\r\n\t}\r\n\treturn m;\r\n}\r\n\r\nint lcm(int m,int n){\r\n return ((m/gcd(m,n))*n);\r\n}\r\n\r\nll choose(ll n, ll r){\r\n ll i;\r\n ll p=1;\r\n for (i=1;i<=r;i++)\r\n p=p*(n-i+1)/i;\r\n return p;\r\n}", | |
"set": { | |
"type": "plain" | |
}, | |
"children": [], | |
"id": 1 | |
}, | |
{ | |
"name": "大きな素数で割れ@C++", | |
"data": "\r\n// xのp乗 対数mod\r\n// 逆元...powm(n,E107-2,E107)\r\nll powm(ll x,ll p,ll mod){\r\n ll y=1;\r\n x=x%mod;\r\n while (0<p){\r\n if (p%2==1){\r\n y=(y*x)%mod;\r\n }\r\n x=(x*x)%mod;\r\n p/=2;\r\n }\r\n return y;\r\n}\r\n\r\n// NchooseR のmod版\r\nll choosemod(ll n, ll r,ll mod){\r\n ll i;\r\n ll p=1;\r\n for (i=1;i<=r;i++)\r\n p=(((p*(n-i+1))%mod)*powm(i,mod-2,mod))%mod;\r\n return p;\r\n}\r\n", | |
"set": { | |
"type": "plain" | |
}, | |
"children": [], | |
"id": 2, | |
"directory": "/2" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment