[CF 487C Prefix Product Sequence]】的更多相关文章

题意 将1~n的正整数重排列,使得它的前缀积在模n下形成0~n-1的排列,构造解或说明无解.n≤1E5. 思考 小范围内搜索解,发现n=1,n=4和n为质数时有解. 不难发现,n一定会放在最后,否则会多出很多的0. 1.n≥4且n为合数:由于n能写成pq的形式,其中pq|(n-1)!,因此第n-1的位置上一定为0,故无解. 2.n为质数:按以下方式构造.令答案ai=i*(i-1)-1(若i-1=0,令其逆元为1).则其前缀积为1,2,3,...,n-1,0.由于i*(i-1)-1=j*(j-1)…
意甲冠军: 对于数字n, 他询问是否有1~n置换 这种布置能够在产品上模每个前缀n 有可能0~n-1 解析: 通过观察1肯定要在首位,n一定要在最后 除4意外的合数都没有解 其它质数构造 a[i]=i*inv[i-1] , 这样用逆元把前面每一个数的影响都消除掉 C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input outpu…
题目链接 \(Description\) 对于一个序列\(a_i\),定义其前缀积序列为\(a_1\ \mathbb{mod}\ n,\ (a_1a_2)\ \mathbb{mod}\ n,...,(a_1a_2...a_n)\ \mathbb{mod}\ n\). 给定\(n\),求一个\(n\)的排列,使得该排列的前缀积序列是\([0,1,2,...,n-1]\)的一个排列.无解输出\(NO\). \(n\leq10^5\). \(Solution\) 考虑无解的情况.因为\(n!\equi…
传送门 题目大意 分析 因为n为质数所以i-1的逆元唯一 因此ai唯一 代码 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cctype> #include<cmath> #include<cstdlib> #include<queue> #inc…
题目链接: C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence . Now given n, find a permutation…
Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence . Now given n, find a permutation of [1, 2, ..., n], such that its prefix product sequence is a permutation of [0, 1, ..., n - 1]. Input The only input line contains an intege…
大意: 构造一个[1,2,...n]的排列, 使得前缀积模n为[0,1,...,n-1]的排列 这种构造都好巧妙啊, 大概翻一下官方题解好了 对于所有>=6的合数$n$, 有$(n-1)! \equiv 0 \space (mod \space n)$, 一定不成立 对于素数可以构造$[1,\frac{2}{1},\frac{3}{2},\frac{4}{3},...,\frac{n-1}{n-2},n]$, 或者构造$[1,g,g^{-2},g^3,g^{-4},...,n]$, $g$为$n…
题目链接: 传送门 Domino Effect time limit per test:1 second     memory limit per test:256 megabytes Description Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix. The dot product…
http://codeforces.com/contest/602/problem/D 这题需要注意到的是,对于三个点(x1, y1)和(x2, y2)和(x3, y3).如果要算出区间[1, 3]的L(h)函数的最大值,则一定不会是 通过(y3 - y1) / (x3 - x1)算出.因为很简单,通过(x2, y2)作为辅助点,数值将会更加大. 然后设dis[i]表示abs(a[i + 1] - a[i]).那么区间[L, R]的最大值就是在dis[]中,[L, R - 1]数值的最大值. 因…
当时脑残了, 不会写矩阵快速幂中更改的系数, 其实把他扔到矩阵里同时递推就好了 #include<cstdio> #include<algorithm> #include<cstring> #include<queue> #include<iostream> #define ll long long using namespace std; ll read() { ll nm = 0, f = 1; char c = getchar(); for…