0分,求助
查看原帖
0分,求助
1280343
a111111111111楼主2024/5/12 10:41
#include<bits/stdc++.h>
using namespace std;
int poww(int a,int b)
{
    for(int x=1;x<=b;x++) a*=b;
    return a;
}
int ff(int a,int w)
{
	w=poww(10,w-1);
	return (a-floor((float)a/(w*10))*(w*10)-a%w)/w;
}
int f(int a,int w,int b,int c,int d,int e)
{
    while(--w)
    {
        int s=ff(a,w);
        if(s!=b && s!=c && s!=d && s!=e) return 0;
        else return a;
    }
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);int n,z; cin>>n;
	for(int x=1;x<=n;x++)
	{
	    if(x<10) z+=f(x,1,2,0,1,9);
	    else if(x<100) z+=f(x,2,2,0,1,9);
	    else if(x<1000) z+=f(x,3,2,0,1,9);
	    else if(x<10000) z+=f(x,4,2,0,1,9);
	    else z+=f(x,5,2,0,1,9);
	}
	cout<<z;
	return 0;
}
2024/5/12 10:41
加载中...