07 2012 档案
摘要:1 #include "stdio.h" 2 #include "stdlib.h" 3 4 // using back tracking solve the problem 5 6 int N = 8; 7 8 int a[N]={0}, b[2*N-1]={0}, c[2*N-1]={0}; 9 char queen[N];10 /*11 * a[col-1] 记录第 col 列有无皇后, 1 表示有。12 * b[row+col-2] 记录从左上数第 row+col-1 条斜率为 1 的线上有无皇后。13 * c...
阅读全文
摘要:Little Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Terna
阅读全文
摘要: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
阅读全文
摘要:熟悉编程的同学都知道,当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; //*...
阅读全文

浙公网安备 33010602011771号