博弈論記的筆記直接關機給沒了,挺桑心的。算了,不重寫了吧。
附上鍊接:https://blog.csdn.net/Hi_KER/article/details/81188352
對於數據小又容易超時的題,可以採取打表法
打表就是將所有輸入情況的答案保存在代碼中,輸入數據後直接輸出就可以了
打表法具有快速,易行(可以寫暴力枚舉程序)的特點,缺點是代碼可能太大,或者情況覆蓋不完
對於不會超時,數據規模適合打表,爲了簡潔你也可以打表
問題:https://www.luogu.org/problemnew/show/P1149
#include<bits/stdc++.h>
using namespace std;
int res[2000];
int main(){
int a[10]={6,2,5,5,4,5,6,3,7,6};
res[0]=6;
for(int i=1;i<=2000;i++){
int k=i;int temp=0;
while(k){
temp+=a[k%10];
k/=10;
}
res[i]=temp;
}
int n=0;
again:
int num=0;
for(int i=0;i<=999;i++){
for(int j=0;j<=999;j++){
if(n==res[i]+res[j]+res[i+j]+4)
num++;
}
}
cout<<num<<endl;
if(n<24) {
n++;
goto again;
}
return 0;
}
提交:
#include<bits/stdc++.h>
using namespace std;
int a[100]={0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,8,9,6,9,29,39,38,65,88,128};
int main(){
int n;
cin>>n;
cout<<a[n]<<endl;
return 0;
}
。。。。沒寫完,以後再修改吧。