链接

题意从尾部找第一个非0的数 这样就可以考虑下怎样会形成0  这个都知道 只有因子2和因子5相遇会形成0 那这样可以先把所有的2和5先抽出来,这样就保证了其它的数相乘就不会再出现0了 这样就可以转换成尾数相乘的结果 当然可能2的个数会剩余 这一部分留到最后去算

step1 抽出所有的5和2  n!里因子x的个数 求法: n/x+gn(n/x);

这样结果就为1 3 7 9 之一  这样就需要求一下尾部3,,7,9的出现的次数,并且可以发现它们都是以4为周期的 包括2

step2 尾部3 7 9出现的次数 f[n] + find(n/2) 因为抽走了2  x出现的次数g[n][x] = n/10+(n%10>=x)+ggn(n/5)因为抽走了5

最后再把2的影响补上

题意求N!/(n-m)!  因为N!包含(n-m)! 故可以通过各个数出现的次数相减求得最后的结果

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int o[][];
int p[][];
int gn(int n,int x)
{
if(n==)
return ;
return n/+(n%>=x)+gn(n/,x);
}
int ggn(int n,int x)
{
if(n==)
return ;
return gn(n,x)+ggn(n/,x);
}
int find0(int n,int x)
{
if(n==) return ;
return n/x+find0(n/x,x);
}
int main()
{
int n,m;
p[][] = ,p[][] = ,p[][] = ,p[][] = ;
p[][] = ,p[][] = ,p[][] = ,p[][] = ;
p[][] = ,p[][] = ,p[][] = ,p[][] = ;
p[][] = ,p[][] = ,p[][] = ,p[][] = ;
while(cin>>n>>m)
{
memset(o,,sizeof(o));
m = n-m;
o[][] = find0(n,);
o[][] = find0(m,);
o[][] = find0(n,);
o[][] = find0(m,); o[][] = ggn(n,);
o[][] = ggn(n,);
o[][] = ggn(n,);
o[][] = ggn(m,);
o[][] = ggn(m,);
o[][] = ggn(m,);
o[][] -= o[][];
o[][] -= o[][];
int a = o[][]-o[][];
int b = o[][]-o[][];
int c = o[][]-o[][];
int k = o[][]-o[][];
int ans = ;
if(a) ans*=p[][a%];
if(b) ans*= p[][b%];
if(c) ans*= p[][c%];
if(k) ans*= p[][k%];
cout<<ans%<<endl;
}
return ;
}

POJ1150he Last Non-zero Digit(组合)的更多相关文章

  1. [Swift]LeetCode902. 最大为 N 的数字组合 | Numbers At Most N Given Digit Set

    We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}.  (Not ...

  2. BZOJ 4421: [Cerc2015] Digit Division 排列组合

    4421: [Cerc2015] Digit Division 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4421 Descripti ...

  3. [LeetCode] 902. Numbers At Most N Given Digit Set 最大为 N 的数字组合

    We have a sorted set of digits D, a non-empty subset of {'1','2','3','4','5','6','7','8','9'}.  (Not ...

  4. Digit Division(排列组合+思维)(Gym 101480D )

    题目链接:Central Europe Regional Contest 2015 Zagreb, November 13-15, 2015 D.Digit Division(排列组合+思维) 题解: ...

  5. [leetcode] 题型整理之排列组合

    一般用dfs来做 最简单的一种: 17. Letter Combinations of a Phone Number Given a digit string, return all possible ...

  6. Project Euler 90:Cube digit pairs 立方体数字对

    Cube digit pairs Each of the six faces on a cube has a different digit (0 to 9) written on it; the s ...

  7. 【CF521C】【排列组合】Pluses everywhere

    Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote ...

  8. USB组合设备 Interface Association Descriptor (IAD)

    Communication Device Class,简称CDCUSB Compound Device,USB复合设备USB Composite Device,USB组合设备 摘要USB复合设备 Co ...

  9. php如何判断字符串是否是字母和数字的组合

    转载自百度 /其实判断是否是字母和数字或字母数字的组合还可以用PHP ctype_alnum函数 if(!ctype_alnum($vipurl)){ echo '只能是字母或数字的组合';exit; ...

随机推荐

  1. Serialization and deserialization are bottlenecks in parallel and distributed computing, especially in machine learning applications with large objects and large quantities of data.

    Serialization and deserialization are bottlenecks in parallel and distributed computing, especially ...

  2. WIFI的通信知识整理

    这两天在解决wifi芯片的一个底层问题,看了很多资料,下面做一个简要记录: 1.信号调制的基本原理 链接:http://wenku.baidu.com/link?url=3K6Z5fBIN20lPzB ...

  3. 关于ie6 下背景图片不透明以及Img不透明

    ie6 下背景图片不透明的方法,加上下面的js即可解决 //解决IE6下图片不透明 function correctPNG() // correctly handle PNG transparency ...

  4. 大O符号

    大O 就是 时间复杂度.时间复杂度是大概的描述一个算法的用时(实际上从侧面的表达了他的效率) 最好时间复杂度,通常指在最好情形下,这个算法用时.反之,最坏情况下的就是最坏时间复杂度.通常 冒泡算法 的 ...

  5. VMWare Workstation 配置docker多macvlan网络方法

    VMWare Workstation 配置docker多macvlan网络方法 答案就是.....换VirtualBox 噗... VMWare Workstation host-only网络,三台虚 ...

  6. bzoj4105: [Thu Summer Camp 2015]平方运算

    填坑 我不知道怎么算的,但是所有环的LCM数不会超过60 然后用线段树维护这个东西,每个节点记录子树内的循环节 没到循环节的暴力枚举 复杂度是nlogn再乘以循环节长度 #include<cst ...

  7. 「网络流24题」「LuoguP4014」 分配问题

    Description 有 n 件工作要分配给 n 个人做.第 i 个人做第 j 件工作产生的效益为 cij.试设计一个将 n 件工作分配给 n 个人做的分配方案,使产生的总效益最大. Input 文 ...

  8. 「LuoguT36048」 Storm in Lover

    Description 平成二十四年(2012年),5月11日,东京,某弓道场. "呐,呐,海未酱,你听说了吗?几天后的那场弓道大会?啊-!"橙发少女兴奋地拿着一张传单一样的纸跑向 ...

  9. Watir: Watir webdriver对JS 弹出框的操作现在非常简单。

    以下代码支持Firefox,IE,Chrome require 'watir-webdriver' #require "watir-webdriver/extensions/alerts&q ...

  10. bzoj2560串珠子——子集DP

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2560 转载: 很明显的状压dp 一开始写的dp可能会出现重复统计的情况 而且难以去重 假设 ...