摘要: P4071 [SDOI2016]排列计数C(n,m)*f[n-m],f函数为错排数,特判n==m的时候,ans=1 阅读全文
posted @ 2019-08-07 21:06 WeiAR 阅读(159) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include #define inf 2147483647 #define N 1000010 #define p(a) putchar(a) #define For(i,a,b) for(long long i=a;i'9'){if(c=='-')y=-1;c=getchar();} ... 阅读全文
posted @ 2019-08-07 20:21 WeiAR 阅读(208) 评论(0) 推荐(0) 编辑
摘要: P2054 [AHOI2005]洗牌https://www.luogu.org/problem/P2054手推一下小数据,会发现,当前编号是x的拍,再进行m次洗牌之后的位置为(2^m)*x%(n+1);所以我们要解这个方程组--> (2^m)*x%(n+1)==lx=l*((2^m)^-1)%(n+ 阅读全文
posted @ 2019-08-07 19:34 WeiAR 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 贝祖定理贝祖定理可以推广到n个,n>=2ax+by+cz+...=kif(k%gcd(a,b,c,...)==0) 该式子有整数解else 没有整数解 阅读全文
posted @ 2019-08-07 15:31 WeiAR 阅读(436) 评论(0) 推荐(0) 编辑
摘要: https://vjudge.net/problem/CodeForces-510D题目可以转化为花最小代价选一些数,然后这些数可以经过加减运算得到1或-1,不然1你就凑不出来,一旦凑出来1,其他的都有了。由贝祖定理,ax+by=gcd(a,b)=1,贝祖定理能推广到n个,ax+by+cz+…=gc 阅读全文
posted @ 2019-08-07 15:28 WeiAR 阅读(138) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include #include #define inf 2147483647 #define N 1000010 #define p(a) putchar(a) #define For(i,a,b) for(int i=a;im; void in(int &x){ int y=1;... 阅读全文
posted @ 2019-08-07 10:44 WeiAR 阅读(131) 评论(0) 推荐(0) 编辑