• HDU6440 Dream(费马小定理+构造) -2018CCPC网络赛1003


    题意:

    给定素数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-6;
    const int mod = 1e9+7;
    const int maxn = 2e5+2;
    const int maxm = 2e6+100;
    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 = 0; i < n; i++){
                    for(ll j = 0; j < n; j++){
                        printf("%I64d ", (ll)(i+j)%n);
                    }
                    printf("
    ");
                }
                for(ll i = 0; i < n; i++){
                    for(ll j = 0; j < n; j++){
    
                        printf("%I64d ", (ll)i*j%n);
                    }
                    printf("
    ");
                }
            
        }
        return 0;
    }
  • 相关阅读:
    Drupal忘记管理员密码
    Drupal7新装一个主题时页面白屏,如何设置一个默认主题?
    Drupal7强制把主题恢复到默认主题
    Drupal常用的模块
    网页流量分析系统
    S运算符&&和|| 及其优先级
    Linux crontab命令
    C语言实现文件实时更新
    Linux 查看设置系统语言
    Python沙盒环境配置
  • 原文地址:https://www.cnblogs.com/wrjlinkkkkkk/p/9538508.html
Copyright © 2020-2023  润新知