hdu-1066(大数)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1066
思路:统计2的个数,如果遇到5,就抵消,最后求和加上为来得及抵消的2的个数。
参考文章:https://www.cnblogs.com/bo-tao/archive/2012/08/08/2627787.html
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char str[];
int a[],mod[]={,,,,,,,,,,,,,,,,,,,};//前20个数的阶乘的非0余数
void f(char* s)
{
int l=strlen(s),i,j,ans,tp;
if(l==)
{
cout<<mod[s[]-'']<<endl;
return ;
}
for(i=l-;i>=;i--) a[l-i-]=s[i]-'';
ans=;
for(i=l;i>;i-=!a[i-])
{
ans=(ans*mod[a[]%*+a[]])%; //统计遇到的2
tp=;
for(j=i-;j>=;j--) //去掉遇到的5
{
tp=tp*+a[j];
a[j]=tp/;
tp%=;
}
}
cout<<ans+ans%*<<endl; //加上遇到的2的个数
}
int main(void)
{
while(~scanf("%s",str))
{
f(str);
}
return ;
}
hdu-1066(大数)的更多相关文章
- HDU 1066 Last non-zero Digit in N!(数论,大数,wait)
The expression N!, read as "N factorial," denotes the product of the first N positive inte ...
- hdu 1002大数(Java)
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 5047 大数找规律
http://acm.hdu.edu.cn/showproblem.php?pid=5047 找规律 信kuangbin,能AC #include <stdio.h> #include & ...
- hdu 5050 大数
http://acm.hdu.edu.cn/showproblem.php?pid=5050 大数模板最大公约数 信kuangbin,能AC #include <cstdio> #incl ...
- hdu 4759 大数+找规律 ***
题目意思很简单. 就是洗牌,抽出奇数和偶数,要么奇数放前面,要么偶数放前面. 总共2^N张牌. 需要问的是,给了A X B Y 问经过若干洗牌后,第A个位置是X,第B个位置是Y 是不是可能的. Ja ...
- HDU 1018 大数(求N!的位数/相加)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- HDU 4927 大数运算
模板很重要 #include <cstdio> #include <cstring> #include <cstdlib> #include <iostrea ...
- hdu 5429(大数模板)
题意:判断是否是等比数列 a[i] * a[i] = a[i+1] * a[i-1] + 部分为0 的情况 /* 表示还没学java.... ,模板来自NK_test #include &l ...
- HDU中大数实现的题目,持续更新(JAVA实现)
HDU1002:大数加法,PE了N次 import java.util.Scanner; import java.math.*; public class Main { public static v ...
- HDU 4099 大数+Trie
Revenge of Fibonacci Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 204800/204800 K (Java/ ...
随机推荐
- bootStrap的小知识
代码模块 <code> 内联代码 <kbd> 用户输入 <pre>代码段 <var>数学字符 <samp>程序输出 表格 <thead ...
- java自定义线程池
如果并发的线程数量很多,并且每个线程都是执行一个时间很短的任务就结束了,这样频繁创建线程就会大大降低系统的效率,因为频繁创建线程和销毁线程需要时间.那么有没有一种办法使得线程可以复用,就是执行完一个任 ...
- as2 fla 关于影片在时间轴的问题
多帧上面放着没实例名而且里面内容一致的影片,主要一开始读取了,那么跳帧的时候.会自动获取当前帧上的相同内容的影片. 但如果内容不一致的影片,那么在跳帧后,不会获取当前的影片,旧的影片也无法获取.只在当 ...
- php, postgresql 安装
sudo yum install postgresql84-server postgresql84-contrib ubuntu下面安装的问题解决: Postgresql installation o ...
- python 冷知识点
# int could accept parameters in bool type.int(True) # result is 1 int(False) # result is 0 reprlib. ...
- jenkins 没有maven选项,怎么办
第一步: 进入jenkins,点系统管理 第二:插件管理 点击“可选插件” 然后在右边的过滤输入框中输入搜索关键字: Maven Integration 或者 Pipeline Maven Int ...
- CSS中不透明度继承问题的处理
关于CSS中不透明度的设置,除了兼容方面的问题,还有不透明度继承问题,这里只讨论下后者. 那么, 什么时候会发生不透明度继承问题? 当文档结构中有父子嵌套关系的时候,并且父元素有不透明度属性设置时,会 ...
- 富文本编辑器-UEditor
官方网址:http://ueditor.baidu.com/website/index.html 下载地址:http://ueditor.baidu.com/website/download.html ...
- unity 返回子对象组件
Component[] GetComponentsInChildren(Type t, bool includeInactive = false); //includeInactive: 是否查找非激 ...
- redis-trib.rb报错:/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- redis (LoadError)
报错如下: /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- redis ...