487C Prefix Product Sequence
题目大意
分析
因为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的更多相关文章
- Codeforces 487C. Prefix Product Sequence 逆+结构体
意甲冠军: 对于数字n, 他询问是否有1~n置换 这种布置能够在产品上模每个前缀n 有可能0~n-1 解析: 通过观察1肯定要在首位,n一定要在最后 除4意外的合数都没有解 其它质数构造 a[i]=i ...
- Codeforces.487C.Prefix Product Sequence(构造)
题目链接 \(Description\) 对于一个序列\(a_i\),定义其前缀积序列为\(a_1\ \mathbb{mod}\ n,\ (a_1a_2)\ \mathbb{mod}\ n,...,( ...
- [CF 487C Prefix Product Sequence]
题意 将1~n的正整数重排列,使得它的前缀积在模n下形成0~n-1的排列,构造解或说明无解.n≤1E5. 思考 小范围内搜索解,发现n=1,n=4和n为质数时有解. 不难发现,n一定会放在最后,否则会 ...
- codeforces 487C C. Prefix Product Sequence(构造+数论)
题目链接: C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes in ...
- cf487C Prefix Product Sequence
Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence . Now given n, find a per ...
- Prefix Product Sequence CodeForces - 487C (数论,构造)
大意: 构造一个[1,2,...n]的排列, 使得前缀积模n为[0,1,...,n-1]的排列 这种构造都好巧妙啊, 大概翻一下官方题解好了 对于所有>=6的合数$n$, 有$(n-1)! \e ...
- codeforces 练习
codeforces 627 D. Preorder Test 二分 + 树dp 做logn次树dp codeforces 578D.LCS Again 给出一个字符串str,长度n<=10^6 ...
- Subarray Product Less Than K LT713
Your are given an array of positive integers nums. Count and print the number of (contiguous) subarr ...
- Adding Pagination 添加分页
本文来自: http://www.bbsmvc.com/MVC3Framework/thread-206-1-1.html You can see from Figure 7-16 that all ...
随机推荐
- Fragment详解及举例
1.为什么用Fragment(Android3.0提出)来替代TabActivity(Android4.0以后正式被弃用)? 因为Fragment可以适应各种不同屏幕大小,也就是适应不同屏幕的分辨率. ...
- 通信对象System.ServiceModel.Channels.ServiceChannel 无法用于通信,因为其处于“出错”状态。
问题描述:在客户端站点访问WCF服务后,在页面停留时间过长,客户端站点将会报错.报错内容如下: 通信对象System.ServiceModel.Channels.ServiceChannel 无法用于 ...
- 窗口玻璃特效,半透明窗口,使用DWM实现Aero Glass效果
转自:http://blog.csdn.net/ntwilford/article/details/5656633 从Windows Vista开始,Aero Glass效果被应用在了Home Pre ...
- UVA10674 Tangents
题意 PDF 分析 就是圆的切线的模板. 注意精度问题,排序的时候也不能直接写,被卡了好几次. 时间复杂度\(O(T)\) 代码 #include<iostream> #include&l ...
- [翻译]Web开发牛人访谈:你们都在用什么?
小肥鱼译注:早上看到这篇文章,觉得内容甚是有趣.作者跟web开发方面的诸多大牛进行了交流,了解到他们的研究动向,从访谈中可以看到各种风格的开发者,有浏览器控,有设备控.我想,知道行业里的优秀成员在做些 ...
- awk 内容
awk相关内容 #只要文件中的路径,不要文件名: [ ...
- 导出csv xls文件数字会自动变科学计数法的解决方式
将数据导出excel文件变成科学计数法问题: 分析: 用程序导出的csv文件,当字段中有比较长的数字字段存在时,在用excel软件查看csv文件时就会变成科学技术法的表现形式. 其实这个 ...
- 你知道PING功能是怎么实现的吗
以太网的协议有层,而每层都包含有更多的协议.所谓协议,通俗的讲就是通信双方约定的规则. 今天我们介绍一些一个听起来陌生却有很常用的协议,ICMP协议. ICMP是(Internet Control ...
- UE4事件相关总结
转自:http://blog.ch-wind.com/ue4-event-overview/ 事件机制是实现游戏内逻辑的重要部分,在开始进行游戏逻辑的设计和实现之前,对UE4的事件机制进行理解是非常必 ...
- C#三层架构实例
对于三层的概念查也查了,看也看了,下面是我找的一个关于三层的简单实例,真正看一下它是如何具体实现的. 我们先来一起看看 实体类-Model 实质:实体类就是在完成数据库与实体类对应的功能,一个类是一张 ...