首页 > 其他 > 详细

UVA10212 【The Last Non-zero Digit.】

时间:2018-05-10 21:19:34      阅读:182      评论:0      收藏:0      [点我收藏+]

暴力可做!!!(十秒还不打暴力!!!)
暴力算阶乘
边算边取余
上代码

#include<iostream>
#define int long long        //开long long
using namespace std;
const int mod=1e9;
signed main()
{
    int n,m;
    while(scanf("%lld%lld",&n,&m)==2)   //多组数据
    {
        int ans=1;
        while(m--)
        {
            ans*=n--;
            while(ans%10==0)
                ans/=10;    //统计末尾0的个数
            ans%=mod;
        }
        printf("%lld\n",ans%10);
    }
    return 0;
}

 

UVA10212 【The Last Non-zero Digit.】

原文:https://www.cnblogs.com/ivanovcraft/p/9021656.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!