题目:http://acm.hdu.edu.cn/showproblem.php?pid=3123

题意很简单,就是同余模的简单应用。

代码如下:

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
typedef __int64 ll;
using namespace std;
char a[];
int n,m;
ll zan,sum;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s%d",a,&m);
sum=;
int l=strlen(a);
if(l>=) n=;
else
{
n=;
for(int i=;i<l;i++)
{
if(i!=) n*=;
n=n+(a[i]-'');
}
}
zan=;
if(n==)
{
printf("%d\n",%m);
continue;
}
else if(n==)
{
printf("%d\n",%m);
continue;
}
if(n>=m) n=m-;
for(int i=;i<=n;i++)
{
zan=(zan*i)%m;
sum=(sum+zan)%m;
}
sum%=m;
printf("%I64d\n",sum);
}
return ;
}

HDU3123:GCC(同余模简单题)的更多相关文章

  1. BZOJ 2683: 简单题

    2683: 简单题 Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 913  Solved: 379[Submit][Status][Discuss] ...

  2. 【BZOJ-1176&2683】Mokia&简单题 CDQ分治

    1176: [Balkan2007]Mokia Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 1854  Solved: 821[Submit][St ...

  3. Bzoj4066 简单题

    Time Limit: 50 Sec  Memory Limit: 20 MBSubmit: 2185  Solved: 581 Description 你有一个N*N的棋盘,每个格子内有一个整数,初 ...

  4. Bzoj2683 简单题

    Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 1071  Solved: 428 Description 你有一个N*N的棋盘,每个格子内有一个整数, ...

  5. 这样leetcode简单题都更完了

    这样leetcode简单题都更完了,作为水题王的我开始要更新leetcode中等题和难题了,有些挖了很久的坑也将在在这个阶段一一揭晓,接下来的算法性更强,我就要开始分专题更新题目,而不是再以我的A题顺 ...

  6. [BZOJ2683][BZOJ4066]简单题

    [BZOJ2683][BZOJ4066]简单题 试题描述 你有一个N*N的棋盘,每个格子内有一个整数,初始时的时候全部为0,现在需要维护两种操作: 命令 参数限制 内容 1 x y A 1<=x ...

  7. HDU 1753 大明A+B(字符串模拟,简单题)

    简单题,但要考虑一些细节: 前导0不要,后导0不要,小数长度不一样时,有进位时,逆置处理输出 然后处理起来就比较麻烦了. 题目链接 我的代码纯模拟,把小数点前后分开来处理,写的很繁杂,纯当纪念——可怜 ...

  8. 团体程序设计天梯赛-练习集L1-014. 简单题

    L1-014. 简单题 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 这次真的没骗你 —— 这道超级简单的题目没有任何输入. ...

  9. bzoj 4066: 简单题 kd-tree

    4066: 简单题 Time Limit: 50 Sec  Memory Limit: 20 MBSubmit: 234  Solved: 82[Submit][Status][Discuss] De ...

随机推荐

  1. 向服务器发送josn字符串,服务器端解析

    <script type="text/javascript"> $(function () { $("#btnsave").click(functi ...

  2. php 判断查询结果是否为空

    select count(people) c from people where people='乐乐' 上面这条sql就是原理 php利用代码 <?php $p=$_POST['p']; $c ...

  3. TMS320C64x DSP L1 L2 Cache架构(1)——C64x Cache Architecture

    [前沿]研究生阶段从事于DSP和FPGA技术的相关研究工作,学习并整理了大量的技术资料,包括TI公司的官方文档和网络上的详细笔记,花费了大量的时间和精力总结了前人的工作成果.无奈工作却从事于嵌入式技术 ...

  4. 模拟form表单请求上传文件

    发请求 public string CameraFileUpload(string url,string path,string serverPath,string uploadfileName) { ...

  5. js中的问题(this)(遍历对象中的属性)

    for (var i in this) { if (this[i] == null) this[i] = "";//属性如果为null,则默认为"";      ...

  6. SecureCRT 常用技巧

    转自:http://blog.chinaunix.net/uid-26575352-id-3063143.html 快捷键: 1. ctrl + a :  移动光标到行首 2. ctrl + e :移 ...

  7. leetcode -- Best Time to Buy and Sell Stock III TODO

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  8. [置顶]JB开发之制作系统级Application

    1.编译工程,生成xx.app 2.制作引导进程xx替换xx.app里面的xx进程 引导进程代码: int main(int argc, char *argv[]) { @autoreleasepoo ...

  9. Xmanager连接图形界面

    1.编辑gnome配置文件vim /etc/gdm/custom.conf # GDM configuration storage [daemon]RemoteGreeter= /usr/libexe ...

  10. Codelf 搜索开源代码帮程序员命名

    "计算机科学里两件最难的事:缓存失效和命名." Codelf通过搜索在线开源平台Github, Bitbucket, Google Code, Codeplex, Sourcefo ...