传送门

题目大意

分析

因为n为质数所以i-1的逆元唯一

因此ai唯一

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
#define int long long
using namespace std;
int inv[];
inline bool p(int x){
for(int i=;i*i<=x;i++)
if(x%i==)return ;
return ;
}
signed main(){
int n,m,i,j,k;
scanf("%lld",&n);
if(n==){
puts("YES");
printf("1\n");
return ;
}
if(n==){
puts("YES");
printf("1\n3\n2\n4\n");
return ;
}
if(!p(n)){
puts("NO");
return ;
}
puts("YES");
puts("");
inv[]=;
for(i=;i<n;i++){
inv[i]=(n-n/i)*inv[n%i]%n;
printf("%lld\n",i*inv[i-]%n);
}
printf("%lld\n",n);
return ;
}

487C Prefix Product Sequence的更多相关文章

  1. Codeforces 487C. Prefix Product Sequence 逆+结构体

    意甲冠军: 对于数字n, 他询问是否有1~n置换 这种布置能够在产品上模每个前缀n 有可能0~n-1 解析: 通过观察1肯定要在首位,n一定要在最后 除4意外的合数都没有解 其它质数构造 a[i]=i ...

  2. Codeforces.487C.Prefix Product Sequence(构造)

    题目链接 \(Description\) 对于一个序列\(a_i\),定义其前缀积序列为\(a_1\ \mathbb{mod}\ n,\ (a_1a_2)\ \mathbb{mod}\ n,...,( ...

  3. [CF 487C Prefix Product Sequence]

    题意 将1~n的正整数重排列,使得它的前缀积在模n下形成0~n-1的排列,构造解或说明无解.n≤1E5. 思考 小范围内搜索解,发现n=1,n=4和n为质数时有解. 不难发现,n一定会放在最后,否则会 ...

  4. codeforces 487C C. Prefix Product Sequence(构造+数论)

    题目链接: C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes in ...

  5. cf487C Prefix Product Sequence

    Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence . Now given n, find a per ...

  6. Prefix Product Sequence CodeForces - 487C (数论,构造)

    大意: 构造一个[1,2,...n]的排列, 使得前缀积模n为[0,1,...,n-1]的排列 这种构造都好巧妙啊, 大概翻一下官方题解好了 对于所有>=6的合数$n$, 有$(n-1)! \e ...

  7. codeforces 练习

    codeforces 627 D. Preorder Test 二分 + 树dp 做logn次树dp codeforces 578D.LCS Again 给出一个字符串str,长度n<=10^6 ...

  8. Subarray Product Less Than K LT713

    Your are given an array of positive integers nums. Count and print the number of (contiguous) subarr ...

  9. Adding Pagination 添加分页

    本文来自: http://www.bbsmvc.com/MVC3Framework/thread-206-1-1.html You can see from Figure 7-16 that all ...

随机推荐

  1. Redis设计与实现 (二): 链表

    Redis实现为双链表结构, 列表键的底层实现之一就是链表,  发布与订阅, 慢查询, 监视器等功能都用到了链表. Redis本身也使用链表维持多个客户端. 节点定义, 位于 adlist.h/lis ...

  2. LG3374 【模板】树状数组 1

    题意 如题,已知一个数列,你需要进行下面两种操作: 将某一个数加上x 求出某区间每一个数的和 对于100%的数据:N<=500000,M<=500000 分析 cdq分治解决,参照mlys ...

  3. input子系统框架

    废话不多说,直接进入主题.在驱动insmod后,我们应用层对input设备如何操作?以下以全志a64为实例. 在/dev/input/eventX下(X的形成为后续会分析),是内核把接口暴露给应用层, ...

  4. assembly 需要 unload 和 update 的时候怎么办?

    我正在开发公司的业务组件平台,组件池的灵活性要求很高,业务组件都是可以立即更新和及时装配的;目前完成这些功能,有待测试.用appDomain.unload 拆卸assembly 可以,只是用起来比较麻 ...

  5. jquery 如何使用innerHTML

    $("#responsediv") 是个Jquery对象,它Val()是对Value属性赋值对它无意义,Jquery没有innerHTML这个属性,应该这样写$("#re ...

  6. Linux增加Swap分区

    Linux增加Swap分区 dd if=/dev/zero of=/data/swap/swapfile1 bs=4096 count=2097152 mkswap /data/swap/swapfi ...

  7. UBUNTU readelf的安装

    大多数情况下,linux环境上默认可能都装有readelf,但是也有少数情况可能没有装,我自己用的ubuntu的linux虚拟机就没有装readelf.readelf本身是一个分析elf很好用的工具. ...

  8. Eclipse中的maven项目打war包

    在对应的pom文件中,找到packing这个属性,改为war:如果没有,就自己加一个,这个是有默认值的,默认为jar. 例如: <modelVersion>4.0.0</modelV ...

  9. npm国内镜像介绍

    这个也是网上搜的,亲自试过,非常好用! 镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在): 1.通过config命令 npm config set reg ...

  10. C# winform程序免安装.net framework在XP/win7/win10环境运行!(转)

    C# winform程序免安装.net framework在XP/win7/win10环境运行!   前文: 首先感谢群里的大神宇内流云 提供的anyexec for windows版本. 经过本人搭 ...