HDU - 6440 Dream 2018中国大学生程序设计竞赛 - 网络选拔赛
给定的\(p\)是素数,要求给定一个加法运算表和乘法运算表,使\((m+n)^p = m^p +n^p(0 \leq m,n < p)\)。
因为给定的p是素数,根据费马小定理得 \((m+n)^{p-1} \equiv 1(mod\ p)\)
因此,\((m+n)^{p} \equiv m + n\ (mod\ p)\),
同时,\(m^p + n^p \equiv m + n\ (mod\ p)\)。
所以在模p意义下,\((m+n)^p = m^p +n^p(0\leq m,n < p)\) 恒成立,且加法运算与乘法运算封闭。
#include<bits/stdc++.h>
using namespace std;
const int maxn =1e5+5;
typedef long long LL;
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int p;
int T; scanf("%d",&T);
while(T--){
scanf("%d",&p);
for(int i=0;i<p;++i){
for(int j=0;j<p;++j){
printf("%d%c",(i+j)%p,j==p-1?'\n':' ');
}
}
for(int i=0;i<p;++i){
for(int j=0;j<p;++j){
printf("%d%c",(i*j%p),j==p-1?'\n':' ');
}
}
}
return 0;
}
HDU - 6440 Dream 2018中国大学生程序设计竞赛 - 网络选拔赛的更多相关文章
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1001 - Buy and Resell 【优先队列维护最小堆+贪心】
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6438 Buy and Resell Time Limit: 2000/1000 MS (Java/O ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1010 YJJ's Salesman 【离散化+树状数组维护区间最大值】
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/O ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1009 - Tree and Permutation 【dfs+树上两点距离和】
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 hdu 6440 Dream 模拟
Dream Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 Dream hdu6440 Dream 给出一个(流氓)构造法
http://acm.hdu.edu.cn/showproblem.php?pid=6440 题意:让你重新定义任意一对数的乘法和加法结果(输出乘法口诀表和加法口诀表),使得m^p+n^p==(m+n ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 hdu Tree and Permutation 找规律+求任意两点的最短路
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 hdu Find Integer 数论
Find Integer Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 Solution
A - Buy and Resell 题意:给出n个交易点,每次能够选择买或者卖,求获得最大利润 思路:维护两个优先队列,一个是卖,一个是替换,当价格差相同时,优先替换,因为次数要最少 #includ ...
- hdu6444 2018中国大学生程序设计竞赛 - 网络选拔赛 1007 Neko's loop
Neko's loop Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total S ...
随机推荐
- vlc-ts
https://github.com/jiayayao/vlc_2.1.0-vs_2010 https://wenku.baidu.com/view/a0634d26336c1eb91a375d70. ...
- java面试复习题四
一.redis最大缓存和回收策略 二.常用的数据库Druid线程池的参数设置 三.Spring的几大特性和应用 参考 Spring的核心特性就是IOC和AOP,IOC(Inversion of Con ...
- Ext Js 6.2.1 classic grid 滚动条bug解决方案
此bug未在其他版本发现,参考高版本代码重写类解决此bug,直接上代码: /** * 如果列表同时存在横向滚动条和竖向滚动条,当竖向滚动条滚动到底部时 * 点击横向滚动条,滚动条会自动滚动到顶部 * ...
- Linux系统安全之pam后门安装使用详解
一.查看系统pam版本: [root@redkey ~]# rpm -qa | grep pam pam-1.1.1-4.el6.x86_64 二.下载对应版本的pam模块 http://www.li ...
- python开发工具
要用到爬虫,网上推荐crapy,自己在pycharm上没有安装成功,于是使用anaconda,但是在gui界面安装crapy总是失败,且没有提示信息.于是使用命令行的方式,提示PermissionEr ...
- M - COURSES
Consider a group of N students and P courses. Each student visits zero, one or more than one courses ...
- js 函数中的this
资料 function 函数 没有"this"的持久概念, 调用函数时,创建this function hello(thing) { console.log(this + &quo ...
- common lisp的几个基本概念
S-表达式 quote nil 与 () cons car cdr 真假 predicate 谓词与 t 与 nil null 函数 与 not 函数 if then else and 与 or de ...
- python全栈开发 * 09知识点汇总 * 1806011
09 函数初识一 函数的的定义# 函数: 对代码块和功能的封装和定义# 引入 回家过程 未用函数# print("步行")# print("坐地铁")# pri ...
- inner_product
版本1: template < class InputIterator1, class InputIterator2, class T> T inner_product(InputIter ...