CF535B Tavas and SaDDas
Buried_Dream · · 题解
很明显吧,这题是分块打表的板子题。
分块打表很快啊,快如闪电,啪一下就切了。
这题连块长都不用卡,简直是分块打表的模板。
题意:
幸运数字的定义:每一位只含有
找到从
思路:
分块打表,数据范围是
写个判断函数开始打表就行了。
给出打表代码:
bool Check(int x) {
while(x) {
if(x % 10 != 4 && x % 10 != 7) return false;
x /= 10;
}return true;
}
int Bel = 1e5;
int cnt = 0;
signed main() {
for(int i = 1; i <= 1e9; i++) {
if(Check(i)) cnt++;
if(i % Bel == 0) printf("%lld,", cnt), cnt = 0;
}
}
查询答案的时候,整块直接加,散块暴力求。
代码在剪切板里:https://www.luogu.com.cn/paste/x19xe57n