2014022101

#include<stdio.h>//efg---wq*p=qefg----w
void main()
{
    int a, m, j, k, p, q, w[100];
    scanf("%d%d", &q, &p);
    w[1] = q;//211
    m = 0;
    k = 1;
    a = p*q;
    while (a != q)
    {
        a = w[k] * p + m;
        k++;
        w[k] = a % 10;
        m = a / 10;
    }
    for (j = k - 1; j >= 1; j--)
        printf("%d",w[j]);
    printf("\n");
}

#include<stdio.h>//统计n阶乘中数字p的个数
void main()
{
    int n, p, a, m, i, j, k, w[2000], s;
    scanf("%d%d", &n, &p);
    w[0] = 1;
    k = 0;
    for (i = 1; i <= n; i++)
    {
        m = 0;
        for (j = 0; j <= k; j++)
        {
            a = w[j] * i + m;
            w[j] = a % 10;
            m = a / 10;
        }
        while (m > 0)
        {
            k++;
            w[k] = m % 10;
            m = m / 10;
        }
    }
    for (s = 0, i = k; i >= 0; i--)
    {
        printf("%d", w[i]);
        if (w[i] == p)
            s++;
    }
    printf("\n%d\n", s);
}

#include<stdio.h>
void main()
{
    int a, b, p, c, n, t, f;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d", &p);
        c = 0;
        n = 0;
        f = 1;
        while (c != 0 || f != 0)
        {
            a = c * 10 + 1;
            c = a%p;
            b = a / p;
            n++;
            if (f == 1 && b == 0)
                continue;
            printf("%d", b);
            f = 0;
        }
        printf("%d\n", n);
    }
}

#include<stdio.h>
#include<string.h>
void main()
{
    int a, b, p, c, len, m, k, f;
    char buff[10];
    scanf("%d", &p);
    c = 1;
    m = 1;
    f = 0;
    while (c != 0)
    {
        m++;
        sprintf(buff, "%d", m);
        len = strlen(buff);
        k = 0;
        while (k < len)
        {
            a = c * 10 + (buff[k] - '0');
            k++;
            c = a%p;
            b = a / p;
            if (f == 0 && b == 0)
                continue;
            f = 1;
            printf("%d", b);
        }
    }
    printf("%d\n", m);
}

 

posted @ 2014-02-21 22:15  yuanqi  阅读(197)  评论(0编辑  收藏  举报