传送门

题目大意

分析

因为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. 【sqlite】基础知识

    最近做一个数控系统的项目,winCE嵌入式操作系统+.Net Compact Framework环境+VS2008开发平台,开发的设备程序部署到winCE系统下的设备中运行.. 个年头,SQLite也 ...

  2. SqlServer 数据表数据移动

    描述:将Test1表中的数据放到Test2表中 1.Test2表不存在 select A,B,C insert into Test2 from Test1 select * into Test2 fr ...

  3. JAMstack 最佳实践

    摘自官方介绍,没有翻译(没必要,已经比较简单了,重要的就是进行每条的诠释了,后续...) Entire Project on a CDN Because JAMstack projects don’t ...

  4. aop log切面

    @Aspect:描述一个切面类,定义切面类的时候需要打上这个注解 @Component:spring-boot配置类 package com.*.*.tools; import org.aspectj ...

  5. sql中case when的简单使用

    这是一个很多博客都引用的博客,作者未知,但是我第一次看到的就是这个,所以置顶这个吧, 这里有两个我刚才使用的列子: --查询同一机构的签约数和解约数: select t.sgn_acct_issr_i ...

  6. 数据的持久性存储(二)——CoreData(附Demo)

    CoreData是一款稳定.功能全面的持久性工具.(本文参考iphone开发3所写,比较简要,需详细了解可以参考iphone开发3) 首先创建一个新的项目CoraData,记得勾选Use Core D ...

  7. HTMLTestRunner 汉化版---来源一个大神的源码(加了失败截图,用例失败重新执行 功能)

    HTMLTestRunner 汉化版 20170925 测试报告完全汉化,包括错误日志的中文处理 针对selenium UI测试增加失败自动截图功能 增加失败自动重试功能 增加饼图统计 同时兼容pyt ...

  8. 合并石子(dp)

    合并石子 时间限制: 1 Sec  内存限制: 128 MB提交: 7  解决: 7[提交][状态][讨论版][命题人:quanxing] 题目描述 在一个操场上一排地摆放着N堆石子.现要将石子有次序 ...

  9. PHP面向对象深入研究之【对象生成】

    对象 看个例子 <?php abstract class Employee { // 雇员 protected $name; function __construct( $name ) { $t ...

  10. JAVA面试(5)

    这里列出10条JAVA编程经验 1 字符串常量放在前面 把字符串常量放在equals()比较项的左侧来防止偶然的NullPointerException. // Bad if (variable.eq ...