摘要: B. Colorful FieldFox Ciel saw a large field while she was on a bus. The field was a n × m rectangle divided into 1 × 1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.After seeing the field carefully, Ciel found that the crop p 阅读全文
posted @ 2012-07-25 17:34 Double_win 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 熟悉编程的同学都知道,当n=100时,n!已经很大且超过了long的表示范围了。此时需要改变计算结果的存储方式。我采用数组的形式存储结果。相比于传统的迭代 将 (n-1)! 的结果作被乘数, n作乘数。本文将两者的次序变换,可大大简化计算复杂度。 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int res[400000]={0}; 6 int n; 7 while(cin>>n) 8 { 9 res[0]=1;10 int height=1; //*... 阅读全文
posted @ 2012-07-25 17:10 Double_win 阅读(306) 评论(0) 推荐(0) 编辑