摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1290同切西瓜问题一样 阅读全文
posted @ 2011-04-20 18:00 聊聊IT那些事 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 摘自:http://blog.sina.com.cn/s/blog_59e67e2c0100a7yx.html需要慢慢注墨。。。。首先引用下leemars的报告:这道题要求N!的最后一个非0数字是多少,如果用一般作法,先统计2和5的个数,然后补乘2,得到的将是TLE。所以还需要再做简化:为了把0去掉,我们把所有的因数2和5都提出来,放到最后再处理。N!中的N个相乘的数可以分成两堆:奇数和偶数。偶数相乘可以写成(2^M)*(M!),M=N DIV 2。M!可以递归处理,因此现在只需讨论奇数相乘。考虑1*3*5*7*9*11*13*15*17* ... *N(如果N为偶数则是N-1),这里面是5的 阅读全文
posted @ 2011-04-20 17:56 聊聊IT那些事 阅读(1087) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1568看了半天,没思路,摘了一位dn的,学习了!View Code 先看对数的性质,loga(b^c)=c*loga(b),loga(b*c)=loga(b)+loga(c);假设给出一个数10234432,那么log10(10234432)=log10(1.0234432*10^7)=log10(1.0234432)+7;log10(1.0234432)就是log10(10234432)的小数部分.log10(1.0234432)=0.01006374410^0.010063744=1.023443198那 阅读全文
posted @ 2011-04-20 17:11 聊聊IT那些事 阅读(366) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2674小技巧 :当数很大时mod2009就为0了。。。。。。。。View Code #include"iostream"using namespace std;int main(){ int n; int i; while(cin>>n) { int mul=1; if(n<=1000) { for(i=1;i<=n;i++) { mul*=i%2009; mul%=2009; } } else mul=0; cout<<mul<<endl; 阅读全文
posted @ 2011-04-20 16:13 聊聊IT那些事 阅读(282) 评论(0) 推荐(0) 编辑