神奇的数学
對于(4^k-1)/3之類的處理 也就是所說的大數運算,可以通過數學轉化成字符串 即階乘 t=1;(4^k-1)/3={t*=4;t++;}
例如:http://59.69.128.200/JudgeOnline/problem.php?pid=45
也就是所謂的棋盤覆蓋問題
View Code 1 #include<iostream>2 #include<cstring>
3 using namespace std;
4
5 int main()
6 {
7 int n;
8 cin>>n;
9 while(n--)
10 {
11 int a[100];
12 memset(a,0,sizeof(a));
13 int size;
14 cin>>size;
15 a[0]=1;
16 if(size==1)
17 cout<<a[0]<<endl;
18 int i,j,k;
19 for(i=2;i<=size;++i)
20 {
21 for(j=0;j<100;++j)
22 a[j]=4*a[j];
23 a[0]++;
24 for(j=0;j<99;++j)
25 {
26 a[j+1]+=a[j]/10;
27 a[j]=a[j]%10;
28 }
29 }
30
31 for(i=99;i>=0;--i)
32 if(a[i]) break;
33 for(j=i;j>=0;--j)
34 cout<<a[j];
35 cout<<endl;
36 }
37 return 0;
38 }
轉載于:https://www.cnblogs.com/zhaoguanqin/archive/2011/07/29/2121485.html
總結
- 上一篇: Excel文件操作
- 下一篇: ORACLE DUAL表详解