`
blackcoffee
  • 浏览: 55471 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

USACO Training Section 3.2 Factorials

阅读更多
 
英文原题  中文题译

大意:找N!的第一个非0位的值。

一个字:水。

/*
ID: blackco3
TASK: fact4
LANG: C++
*/
#include <iostream>
using namespace std;

int main() {
	freopen("fact4.in", "r", stdin);
	freopen("fact4.out", "w", stdout);
	int n;
	cin >> n ;
	int remain = 1 ;
	for(int i=2; i<=n; i++ ) {
		remain *= i;
		while( !(remain%10) )
			remain /= 10;
		remain %= 10000;
	}
	cout << (remain%10) << endl ;
	return 0;
}
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics