• hdu 3123 2009 Asia Wuhan Regional Contest Online


    以为有啥牛逼定理,没推出来,随便写写就A了----题非常水,可是wa了一次


    n>=m  则n!==0

    注意的一点,最后 看我的凝视

    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #include <iostream>
    
    using namespace std;
    
    const int  maxn = 115;
    #define ll long long
    
    int main()
    {
        int ncase,len;
        ll m,n,ans,rec;
    
        char num[maxn];
        scanf("%d",&ncase);
        while(ncase--)
        {
            ans=rec=1;
            scanf("%s",num);
            len=strlen(num);
            scanf("%I64d",&m);
            if(len > 7)n=m-1;
            else
            {
                n=0;
                for(int i=0;i<len;i++)n=n*10+num[i]-'0';
            }
            for(int i=1;i<=n;i++)//at end +1%m
            {
                rec=rec*i%m;
                ans=(ans+rec)%m;
            }
    
            printf("%I64d
    ",ans%m);/*注意n==0时 未进入循环,測试数据 0 1 应该是0假设不加%m是1*/
        }
    
        return 0;
    }
    


     

  • 相关阅读:
    struts2标签具体解释
    证明N={1,2,...,n,...}最高万元 黄晓宁
    Oracle 11g 环境,使用utl_smtp创建一个存储过程来发送邮件
    通过非暴力促进国内操作系统的可行性分析
    pig 的chararry不能用于比较的类型可以comparison operator
    Tair LDB基于Prefixkey找到如何提取一系列性能优化项目key的prefix_size
    hdu 5073 Galaxy(2014acm鞍山亚洲分部 D)
    乐趣与你rabbitMQ 源代码
    我们的空间是它圆——基于Poicare对宇宙的模型
    自己主动旋转木马,自己主动作为幻灯片标题类似或图片
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10853395.html
  • Copyright © 2020-2023  润新知