Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
1.0 kB
4
Indexable
Never
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef long long ll;
int l,r,m;
int a[100000], nmax;
int min(int a,int b)
{
    if (a < b) return a;
    return b;
}
int check_tn()
{
    int l = 1, r = nmax;
    while (l < r)
    {
        if (a[l] != a[r]) return 0;
        l++;
        r--;
    }
    return 1;
}
int check(int x)
{
    for (int k = m; k >= 2; k--)
    {
        nmax = 0;
        int tmp = x;
        while (tmp)
        {
            int mod = tmp % k;
            if (mod == 0) a[++nmax] = mod;
            else 
            {
                while (mod)
                {
                    a[++nmax] = mod % 10;
                    mod /= 10;
                }
            }
            tmp /= k;
        }
        if (check_tn() == 0) return 0;
    }
    return 1;
}
int main()
{
    scanf("%d %d %d", &l, &r, &m);
    int ans = 0;
    for (int i = l; i <= r; i++) ans += check(i);
    printf("%d", ans);
}
Leave a Comment