zoukankan      html  css  js  c++  java
  • 【bzoj1965】[Ahoi2005]SHUFFLE 洗牌

    x*2^m==l (mod n+1)
    x=(n/2+1)^m*l mod n+1

    #include<algorithm>
    #include<iostream>
    #include<cstdlib>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<queue>
    using namespace std;
     
    typedef long long LL;
     
    #define MOD (LL)(n+1LL)
     
    int n,m,l;
     
    LL qpow(LL a,LL b)
    {
        LL m=a,s=1LL;
        while (b)
        {
            if (b & 1)
                s=(s*m)%(n+1);
            m=(m*m)%(n+1);
           b>>=1;
        }
        return s;
    }
     
    int main()
    {
        scanf("%d%d%d",&n,&m,&l);
        printf("%lld",(qpow((LL)n/2+1,m)*l)%(n+1));
        return 0;
    }
    

      

    #include<algorithm>
    #include<iostream>
    #include<cstdlib>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<queue>
    using namespace std;
     
    typedef long long LL;
     
    #define MOD (LL)(n+1LL)
     
    int n,m,l;
     
    LL qpow(LL a,LL b)
    {
        LL m=a,s=1LL;
        while (b)
        {
            if (b & 1)
                s=(s*m)%(n+1);
            m=(m*m)%(n+1);
           b>>=1;
        }
        return s;
    }
     
    int main()
    {
        scanf("%d%d%d",&n,&m,&l);
        printf("%lld",(qpow((LL)n/2+1,m)*l)%(n+1));
        return 0;
    }
  • 相关阅读:
    Hadoop学习资料收集
    sed使用详解
    shell编程001
    电影《无法触碰》
    正则表达式
    I/O重定向与管道
    bash基础知识
    用户权限模型
    Linux文件管理常用命令
    根文件系统详解
  • 原文地址:https://www.cnblogs.com/yangjiyuan/p/5761035.html
Copyright © 2011-2022 走看看