SPOJ NWERC11B Bird tree

时间:2022-05-08
本文章向大家介绍SPOJ NWERC11B Bird tree,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

题意:根据公式进行分析,当该数字小于1说明往左边走,当数字大于1说明往右边走

#include<stdio.h>
int main()
{
    int T;
    long long a,b,temp;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%lld/%lld",&a,&b);
        while(a!=b)
        {
            if(a>b)
            {
                printf("R");
                temp=b;
                b=a-b;
                a=temp;
            }
            else
            {
                printf("L");
                temp=a;
                a=b-a;
                b=temp;
            }
        }
        printf("n");

    }
    return 0;
}