模拟赛时我遇到了这样一题
看到数据点我就想到了打表 最后还是老老实实暴力
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[10], z;
void f(int t, string s,int pd) {
if (a[4] && a[8])return;
if(t>8&&!pd)return ;
if (t == 11) {
cout << "\"" << s << "\",";
z++;
return ;
}
for (int i = 0; i <= 9; i++) {
a[i]=1;
if(pd==0)f(t+3,s+char(i+'0')+char(i+'0')+char(i+'0'),1);
f(t + 1, s + char(i + '0'),pd);
a[i]=0;
}
}
signed main() {
freopen(".out", "w", stdout);
f(1, "1",0);
f(1, "2",0);
f(1, "3",0);
f(1, "4",0);
f(1, "5",0);
f(1, "6",0);
f(1, "7",0);
f(1, "8",0);
f(1, "9",0);
cout << endl << z;
return 0;
}
结果
删完就好了
一个打表数据80多GB,好像还没打完。
你遇到过80GB的打表数据数据吗?