hdu6440 Dream(费马小定理)

保证  当  n^p=n(mod p) 是成立  只要保证n*m=n*m(mod p);

#include<bits/stdc++.h>
using namespace std;
int main()
{

    int T;scanf("%d",&T);
    while(T--)
    {
        int p;scanf("%d",&p);
        for(int i=0;i<p;i++)
        {
            for(int j=0;j<p;j++)
            {
                if(j!=0) printf(" ");
                printf("%d",(i+j)%p);
            }printf("
");
        }
        for(int i=0;i<p;i++)
        {
            for(int j=0;j<p;j++)
            {
                if(j!=0) printf(" ");
                printf("%d",(i*j)%p);
            }printf("
");
        }
    }
}
原文地址:https://www.cnblogs.com/Andromeda-Galaxy/p/9542375.html