题解:P12377 [蓝桥杯 2023 省 Python B] 2023
HZY1618yzh · · 题解
本题暴力+模拟就能过。
思路
首先,枚举
倒序分解数位可以通过每次不断把枚举到的数一直取余十,但一直取余十会把
那如何判断是否满足条件呢?先看看条件的代码翻译:如果
代码
#include<bits/stdc++.h>
using namespace std;
int a[]={2,0,2,3},top,ans;
int main(){
for(int i=12345678;i<=98765432;i++){
top=0;
int z=i,now[8]={},cnt=0;
while(z){
now[cnt++]=z%10;
z/=10;
}
for(int i=cnt;i>=0;i--)
if(now[i]==a[top]){
top++;
if(top>3) break;
}
if(top>3) continue;
ans++;
}
cout<<ans;
return 0;
}
~给个一键三连吧!~