Ekka Dokka(水题)


Ekka Dokka Time Limit:2000MSMemory Limit:32768KB64bit IO Format:%lld & %llu
SubmitStatus

Description

Ekka and his friend Dokka decided to buy a cake. They both love cakes and that's why they want to share the cake after buying it. As the name suggested that Ekka is very fond of odd numbers and Dokka is very fond of even numbers, they want to divide the cake such that Ekka gets a share ofNsquare centimeters and Dokka gets a share ofMsquare centimeters whereNis odd andMis even. BothNandMare positive integers.

They want to divide the cake such thatN * M = W, whereWis the dashing factor set by them. Now you know their dashing factor, you have to find whether they can buy the desired cake or not.

Input

Input starts with an integerT (≤ 10000), denoting the number of test cases.

Each case contains an integerW (2 ≤ W < 263). AndWwill not be a power of2.

Output

For each case, print the case number first. After that print"Impossible"if they can't buy their desired cake. If they can buy such a cake, you have to printNandM. If there are multiple solutions, then print the result whereMis as small as possible.

Sample Input

3

10

5

12

Sample Output

Case 1: 5 2

Case 2: Impossible

Case 3: 3 4

注:n&1==1表明n为奇数

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int T, ca = 1;
    long long w, m, n, i, j;
    scanf("%d", &T);
    while(T--)
    {
        cin >> w;
        if(w&1) printf("Case %d: Impossible\n", ca++);
        else
        {
            for(m = 2; m < w; m += 2)
            {
                n = w / m;
                if(n * m == w && n&1)
                    break;
            }
            if(m < w) cout << "Case " << ca++ << ": " << n << " " << m << endl;
            else printf("Case %d: Impossible\n", ca++);
        }
    }
    return 0;
}


优质内容筛选与推荐>>
1、layUI学习第一日:myeclipse中使用layUI
2、bootstrap使用modal动态对话框时,按回车键无法确认,反而取消对话框
3、mysq l错误Table ‘./mysql/proc’ is marked as crashed and should be repaired
4、java基础
5、海量长尾关键词挖掘及优化排名策略


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn