高精度阶乘
来源:互联网 发布:淘宝网开店 编辑:程序博客网 时间:2024/05/21 07:47
。。。其实就是高精度乘法的翻版,洛谷水题,不解释了。。。
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>using namespace std;struct T{int x[20000],len;T(int z=0){memset(x,0,sizeof(x));if(z==1){x[0]=1;len=1;}} };T operator *(T a,int b){T res;res.len=a.len;for(int i=0;i<a.len;i++){res.x[i]+=a.x[i]*b;res.x[i+1]+=res.x[i]/10;res.x[i]%=10;}while(res.x[res.len]){res.x[res.len+1]+=res.x[res.len]/10;res.x[res.len]%=10;++res.len;}return res;}int main(){int i,j,k,m,n;int t;scanf("%d",&t);while(t--){T sum=1;scanf("%d%d",&n,&m);for(i=1;i<=n;i++){sum=sum*i;} int ans=0;for(i=sum.len-1;i>=0;i--){if(sum.x[i]==m)ans++;//printf("%d",sum.x[i]);}printf("%d\n",ans);}return 0;}
0 0
- 高精度阶乘
- 高精度阶乘
- 高精度阶乘
- 高精度阶乘
- 高精度阶乘
- 高精度阶乘
- 高精度阶乘
- 高精度阶乘
- 高精度阶乘
- 高精度快速阶乘算法
- 高精度乘法和阶乘
- 高精度阶乘、乘方排列组合
- 高精度算阶乘
- 旧代码 - 高精度阶乘
- 大数_高精度阶乘
- 高精度运算之阶乘
- 阶乘计算(高精度)
- 高精度加法,乘法,阶乘
- 四旋翼飞行器——坐标变换
- 使用JDBC连接数据库
- 【JZOJ4807】破解
- 10.4
- MySql 学习笔记三:常用SQL优化
- 高精度阶乘
- Android gradle实用教程(一):Android studio中的gradle
- linux环境下的vi编辑器详解(一)
- jquery中事件
- android中xml文件的作用及解释
- LinearRegressionWithSGD 问题
- PAT_A 1119. Pre- and Post-order Traversals (30)
- Poj 2785 4 Values whose Sum is 0【二分】
- 算法第四版3-2Binary Search Trees With C++ Implementation