zzuli 2266: number(思维)

这里写图片描述

这题想着大数怎么往小数走抑制了思维 换个思想小数往大数走只需要记录种类即可
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <bits/stdc++.h>
typedef long long LL;
const int N =1e4+100;
using namespace std;
typedef long long LL;
const LL mod =  998244353;
int a[1<<10];

int main()
{
    LL ans=0;
    int n;
    scanf("%d", &n);
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++)
    {
        int x=i, s=0;
        while(x)
        {
            int b=x%10;
            s|=(1<<b);
            x/=10;
        }
        ans+=a[s];
        a[s]++;
    }
    cout<<ans<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/yjf3151731373/article/details/80357942