随笔-141  评论-9  文章-3  trackbacks-0

每次相乘的结果去掉尾部的0 之后,  mod 10000, 仅保留五位.

/*
ID: lorelei3
TASK: fact4
LANG: C++
*/


#include 
<fstream>

using namespace std;

int n;

int main(){

    unsigned 
long res = 1;
    ifstream fin(
"fact4.in");
    ofstream fout(
"fact4.out");

    fin
>>n;


    
for(int i=2; i<=n; ++i){
        res 
*= i;
        
while(res%10==0)
            res 
/=10;
        res 
%= 100000 ;
    }


    fout
<< res%10 <<endl;
        
    
return 0;
}
posted on 2010-12-21 10:14 小阮 阅读(125) 评论(0)  编辑 收藏 引用 所属分类: USACO

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理