题解 | 游游的最小公倍数

游游的最小公倍数

https://www.nowcoder.com/practice/385c7aa397e54bb58f36286ab0d65156

#include <stdio.h>
int main() 
{
    long long int n,a,t;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a);
        if(a==2)
        {
            printf("1 1\n");
        }
        else if(a%2==0)
        {
            t=a/2-1;
            while(t%2==0)
            {
                t-=1;
            }
            printf("%lld %lld\n",t,a-t);
        }
        else 
        {
            printf("%lld %lld\n",a/2,a-a/2);
        }
    }
    return 0;
}

全部评论

相关推荐

等闲_:小红书基本不区分日常和暑期,你是应届实习时间够了就有转正机会,只要部门有hc
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务