题意:

给定素数p,定义p内封闭的加法和乘法,使得$(m+n)^p=m^p+n^p$

思路:

由费马小定理,p是素数,$a^{p-1}\equiv 1(mod\;p)$

所以$(m+n)^{p}\equiv (m+n)(mod\;p)$

$m^{p}\equiv m(mod\;p)$

$n^{p}\equiv n(mod\;p)$

所以在模意义下,有$(m+n)^p=m^p+n^p$

代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 2e5+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); int main() {
int T;
scanf("%d", &T);
while(T--){
ll n;
scanf("%I64d", &n);
for(ll i = ; i < n; i++){
for(ll j = ; j < n; j++){
printf("%I64d ", (ll)(i+j)%n);
}
printf("\n");
}
for(ll i = ; i < n; i++){
for(ll j = ; j < n; j++){ printf("%I64d ", (ll)i*j%n);
}
printf("\n");
} }
return ;
}

最新文章

  1. DuiLib 源码分析之解析xml类CMarkup &amp; CMarkupNode 头文件
  2. web系统架构设计中需要知道的点(前端篇)
  3. Ionic 入门
  4. JAVA正则表达式:Pattern类与Matcher类详解
  5. linux显示-bash-4.2# 问题
  6. hdu 1061 Rightmost Digit
  7. Android Recovery的汉化 显示中文
  8. C语言的指针变量
  9. pwnable.tw silver_bullet
  10. SpringCloud(6)---熔断降级理解、Hystrix实战
  11. Asp.net MVC通过自定义特性实现Action日志记录
  12. 整理:iOS 短信与电话事件的获取
  13. Material Design系列第四篇——Defining Shadows and Clipping Views
  14. ActiveMQ 负载均衡与高可用(转载)
  15. Angular5 UI post 请求 输出 文件下载
  16. BZOJ 1499 [NOI2005] 瑰丽华尔兹 | 单调队列优化DP
  17. MVC 设计模式与三层架构
  18. 运行MySQL远程连接
  19. 装饰器1、无参数的装饰器 2、有参数的装饰器 3、装饰器本身带参数的以及如果函数带return结果的情况
  20. BZOJ 1529 [POI2005]ska Piggy banks(并查集)

热门文章

  1. hadoop上下文信息获取方法
  2. structs2的048漏洞复现 2.3.32版本
  3. 删除centos自带的openjdk
  4. Spring中PropertiesLoaderUtils应用
  5. 你不得不了解Helm 3中的5个关键新特性
  6. express框架中使用nodemon自启动服务
  7. 简单的c语言程序
  8. nacos-docker安装nacos并配置数据库
  9. 自己动手搭环境—unit 1、Struts2环境搭建
  10. 史上最简单的vi教程,10分钟包教会