题目链接:http://codeforces.com/contest/906/problem/D 题目大意:给定n个整数w[1],w[2],……,w[n],和一个数m,然后有q个询问,每个询问给出一个l,r,求w[l]^w[l+1]^w[l+2]……w[r]  %m  ,即a[l]到a[r]的幂次方 解题思路:利用欧拉降幂公式 第一个要求a和p互质,第2个和第3个为广义欧拉降幂,不要求a和p互质,用在这题刚好. 因为有两种情况,所以我们需要自定义一下降幂取模公式. 我们对整个区间进行递归处理,每…
传送门 题目 \[ \begin{aligned} &f_n=c^{2*n-6}f_{n-1}f_{n-2}f_{n-3}&\\ \end{aligned} \] 思路 我们通过迭代发现\(f_n\)其实就是由\(c^{t_1},f_1^{t_2},f_2^{t_3},f_3^{t_4}\)相乘得到,因此我们可以分别用矩阵快速幂求出\(t_1,t_2,t_3,t_4\),最后用快速幂求得答案. 对于\(n<=3\)的我们直接输出即可,\(n>3\)的我们先将\(n\)减去\(3…
D. Tanya and Password Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/508/problem/D Description While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a stri…
D. Recover it! Authors guessed an array aa consisting of nn integers; each integer is not less than 22 and not greater than 2⋅1052⋅105. You don't know the array aa, but you know the array bb which is formed from it with the following sequence of oper…
题意:给你一个数组a,q次查询,每次l,r,要求 \(a_{l}^{a_{l+1}}^{a_{l+2}}...{a_r}\) 题解:由欧拉降幂可知,最多log次eu(m)肯定变1,那么直接暴力即可,还有一个问题是欧拉降幂公式, \(a^{b}mod c=a^{b mod\phi(c)+\phi(c)}mod c(a>c)\) 需要改写快速幂 //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pragma GCC optimize(4)…
目录 codeforces1080A codeforces 1080B codeforces 1080C codeforces 1080D codeforces 1080E codeforces 1080F codeforces1080A 传送门:https://codeforces.com/contest/1080/problem/A 题意:制造一份邀请函需要2份a物品,5份b物品,8份c物品,一个盒子里面有k份物品(可以为a或b或c)问你制造n份邀请函需要用多少个盒子 题解:直接加起来就行…
PROBLEM A. Shockers 题 http://codeforces.com/contest/906/problem/A 906A 907C 解 水题,按照题意模拟一下就行了 如果是 ‘ ! ’,那么该字符串中所有没出现的字符标记为否,如果是 ' . '那么该字符串中出现的字符全部标记为否 #include <iostream> #include <cstring> #include <cmath> #include <cstdio> using…
B:考虑2*m怎么构造.因为要求相邻的数不能再相邻,容易想到黑白染色之类的东西,考虑染个色然后大概把黑点扔一边白点扔一边.显然m<=3时无解.对m>4,m为偶数时,如1 2 3 4 5 6   7 8 9 10 11 12,就变换成1 3 5 2 4 6   8 10 12 7 9 11:m为奇数时,如1 2 3 4 5   6 7 8 9 10,就变换成1 3 5 2 4   7 9 6 8 10(当然奇偶没有本质区别).非常开心的发现我们只要把2*m的方案往下复制就可以得到n*m的方案了.…
A. Masha and bears 题意 人的体积为\(V\),车的大小为\(size\),人能钻进车的条件是\(V\leq size\),人对车满意的条件是\(2V\geq size\). 现知道 熊爸爸能钻进最大的车并且满意 熊妈妈能钻进中等的车并且满意 熊宝宝能钻进最小的车并且满意 Masha能钻进最小的车并且只对它满意 给定四人的体积(保证\(V1\gt V2\gt V3\)),要求给出三辆车的大小. 思路 考思维严谨性的题.// 还是有些怕的 假设三辆车大小分别为\(a,b,c\),…
D. Bear and Tower of Cubes 题目连接: http://www.codeforces.com/contest/680/problem/D Description Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many…