Wednesday, 1 June 2011

uva 694-The collatz sequences

uva 10018-Reverse and Add

#include<stdio.h>
unsigned long reverse(register unsigned long);
int main()
{
    register unsigned long n,num,rev,i;
    //freopen("in.txt","r",stdin);
    scanf("%lu",&n);
    while(n--)
    {
        scanf("%lu",&num);
        for(i=0;;i++)
        {
            rev=reverse(num);
            if(!(num^rev))
                break;
            num=num+rev;
        }
        printf("%lu %lu\n",i,num);
    }
    return 0;
}
unsigned long reverse(register unsigned long num)
{
    unsigned long r=0;
    while(num)
    {
        r=r*10+num%10;
        num=num/10;
    }
    return r;
}

uva 10110-Light,more light

uva 10013-Super long sums

uva 10008-What's Cryptanalysis

uva 900-Brick Wall Patterns

uva 10062-Tell me the frequencies!

uva 10041-Bito's Fanoly

uva 492- Pig-Latin

uva 299-train swapping

uva 10252-Common Permutation