首页 > 其他 > 详细

HDU - 6440(费马小定理)

时间:2018-08-26 11:24:28      阅读:183      评论:0      收藏:0      [点我收藏+]

链接:HDU - 6440

题意:重新定义加法和乘法,使得 (m+n)^p = m^p + n^p 成立,p是素数。技术分享图片,且satisfied that there exists an integer q(0<q<p) to make the set {q^k|0<k<p,kZ} equal to {k|0<k<p,kZ}

题解:

技术分享图片

#include <bits/stdc++.h>
using namespace std;

const double EPS = 1e-6;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int p;

int main()
{
    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(费马小定理)

原文:https://www.cnblogs.com/chenquanwei/p/9536363.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!