gcc【数学几何】
GCC
Time Limit: 1000MS Memory limit: 65536K
题目描述
The GNU Compiler Collection (usually shortened to GCC) is a compiler system produced by the GNU Project supporting various programming languages. But it doesn’t contains the math operator “!”.
In mathematics the symbol represents the factorial operation. The expression n! means "the product of the integers from 1 to n". For example, 4! (read four factorial) is 4 × 3 × 2 × 1 = 24. (0! is defined as 1, which is a neutral element in multiplication, not multiplied by anything.)
We want you to help us with this formation: (0! + 1! + 2! + 3! + 4! + ... + n!)%m.
输入
The first line consists of an integer T, indicating the number of test cases.
Each test on a single consists of two integer n and m.
0 <= n < 10100 (without leading zero)
0 < m < 1000000
输出
Output the answer of (0! + 1! + 2! + 3! + 4! + ... + n!)%m.
示例输入
1
10 861017
示例输出
593846
提示
来源
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
int zong;
cin>>zong;
while(zong--)
{
char str[];
int mod,num;
cin>>str>>mod;
if(strlen(str)>=)
num=;
else sscanf(str,"%d",&num);
if(num>=mod)
num=mod;
long long int yushu1=,i;
long long int yushu2=;
for(i=;i<=num;i++)
{
yushu1=(yushu1*i)%mod;
if(yushu1==)break;
else
{
yushu2+=yushu1;
yushu2=yushu2%mod;
}
}
cout<<yushu2%mod<<endl;
}
return ;
}
gcc【数学几何】的更多相关文章
- hdu 1577 WisKey的眼神 (数学几何)
WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- hdu 1115 Lifting the Stone (数学几何)
Lifting the Stone Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- ACM: FZU 2110 Star - 数学几何 - 水题
FZU 2110 Star Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Pr ...
- poj 1701【数学几何】
The area Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- LightOj1385 - Kingdom Division(数学几何题)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1385 题意:下图中已知面积 a b c 求 d; 如果d的面积不确定,输出-1. 连接 ...
- TZOJ 3244 Happy YuYu's Birthday(数学几何)
描述 9月10日教师节,也是YuYu的生日,妈妈给YuYu准备了一个很大的圆形蛋糕,YuYu看中了蛋糕中间那诱人的樱桃(都挤到一块啦),小家伙很高兴,心里开始盘算着如何将樱桃全部分给自己.YuYu是个 ...
- EOJ Monthly 2018.7 B.锐角三角形(数学几何+思维)
描述 是否存在面积为S/2的整点锐角三角形?存在输出Yes并输出三个整点坐标,否则输出No. 注意如果存在输出的坐标必须在long long范围内. Input 第一行一个整数S(1<=S< ...
- hdu 6097 Mindis(数学几何,圆心的反演点)
Mindis Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- Tell me the area---hdu1798 (数学 几何)
http://acm.hdu.edu.cn/showproblem.php?pid=1798 给你两个圆求阴影部分的面积 求出两个扇形的面积减去四边形的面积 扇形的面积是度数(弧度制)*半径的平方 不 ...
随机推荐
- css选择器(E[att^=”val”]序号选择器)
一.基本选择器序号 选择器 含义1. * 通用元素选择器,匹配任何元素2. E 标签选择器,匹配所有使用E标签的元素3. .info class选择器,匹配所有class属性中包含info的元素4. ...
- tfw格式图解
话不多说,直接看图. 上图中的UV坐标,实际上只的是图像的 横向坐标 和 纵向坐标 .即图像的行和列坐标. 对于图上任意一个像素点(col,row)这个坐标,换算其地理坐标就十分简单. GeoX = ...
- php之CI框架多语言的用法
public function index() { // 加载语言包,可以加载多个 $this->lang->load('email'); echo $this->lang-> ...
- java复制文件
package com.test.tes; import java.io.File; import java.io.FileInputStream; import java.io.FileOutput ...
- ubuntu apt常用命令
apt-cache search packagename 搜索包 apt-cache show packagename 获取包的相关信息,如说明.大小.版本等 apt-get install pack ...
- vs2013 内置IIS Express相关问题
问题描述,以前做的程序迁移到vs2013后出现500.22问题. HTTP 错误 500.22 - Internal Server Error 检测到在集成的托管管道模式下不适用的 ASP.NET 设 ...
- Hexo
Hexo Hexo is a fast, simple & powerful blog framework powered by Node.js.
- 【leetcode】Remove Duplicates from Sorted Array II
Remove Duplicates from Sorted Array II Follow up for "Remove Duplicates":What if duplicate ...
- Qt5.4 MSVC mysql驱动编译;
http://www.mysql.com/ 下载mysql http://download.qt.io/archive/qt/ Qt 下载 1. mysql安装源码 注意勾选这一步,将mysq ...
- UESTC 250
windy数 基本的数位DP,需要判断当前位是否为起始位. #include <cstdio> #include <cmath> #include <cstring> ...