1116 - Ekka Dokka
Time Limit: 2 second(s) Memory Limit: 32 MB

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 of N square centimeters and Dokka gets a share of M square centimeters where N is odd and M is even. Both N and M are positive integers.

They want to divide the cake such that N * M = W, where W is 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 integer T (≤ 10000), denoting the number of test cases.

Each case contains an integer W (2 ≤ W < 263). And W will not be a power of 2.

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 print N and M. If there are multiple solutions, then print the result where M is as small as possible.

Sample Input

Output for Sample Input

3

10

5

12

Case 1: 5 2

Case 2: Impossible

Case 3: 3 4

暴力可以直接过  需要注意的是 n和m都为整数且n为奇数m为偶数

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#define LL long long
#define DD double
#define MAX 10000
using namespace std;
int main()
{
int t;
int m;
LL w,n,i,j;
int ans;
DD ant;
scanf("%d",&t);
int k=1;
while(t--)
{
scanf("%lld",&w);
int flag=0;
printf("Case %d: ",k++);
if(w&1)
{
printf("Impossible\n");
continue;
}
else
{
for(i=2;i<=w/3+4;i++)
{
if(i&1)
continue;
if(w%i==0)
{
n=w/i;
if(n&1)
{
flag=1;
break;
}
}
}
if(flag)
printf("%lld %lld\n",n,i);
else
printf("Impossible\n");
}
}
return 0;
}

  

light oj 1116 - Ekka Dokka的更多相关文章

  1. Light OJ 1116

    基础数学:.. #include<bits/stdc++.h> using namespace std; typedef unsigned long long ULL; int main( ...

  2. Light OJ 1114 Easily Readable 字典树

    题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 ...

  3. Light OJ 1429 Assassin`s Creed (II) BFS+缩点+最小路径覆盖

    题目来源:Light OJ 1429 Assassin`s Creed (II) 题意:最少几个人走全然图 能够反复走 有向图 思路:假设是DAG图而且每一个点不能反复走 那么就是裸的最小路径覆盖 如 ...

  4. Light OJ 1406 Assassin`s Creed 减少国家DP+支撑点甚至通缩+最小路径覆盖

    标题来源:problem=1406">Light OJ 1406 Assassin`s Creed 意甲冠军:向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路: ...

  5. Light OJ 1316 A Wedding Party 最短路+状态压缩DP

    题目来源:Light OJ 1316 1316 - A Wedding Party 题意:和HDU 4284 差点儿相同 有一些商店 从起点到终点在走过尽量多商店的情况下求最短路 思路:首先预处理每两 ...

  6. light oj 1007 Mathematically Hard (欧拉函数)

    题目地址:light oj 1007 第一发欧拉函数. 欧拉函数重要性质: 设a为N的质因数.若(N % a == 0 && (N / a) % a == 0) 则有E(N)=E(N ...

  7. Light OJ 1406 Assassin`s Creed 状态压缩DP+强连通缩点+最小路径覆盖

    题目来源:Light OJ 1406 Assassin`s Creed 题意:有向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路:最少的的人能够走全然图 明显是最小路径覆盖问题 ...

  8. Light OJ 1288 Subsets Forming Perfect Squares 高斯消元求矩阵的秩

    题目来源:Light OJ 1288 Subsets Forming Perfect Squares 题意:给你n个数 选出一些数 他们的乘积是全然平方数 求有多少种方案 思路:每一个数分解因子 每隔 ...

  9. Jan's light oj 01--二分搜索篇

    碰到的一般题型:1.准确值二分查找,或者三分查找(类似二次函数的模型). 2.与计算几何相结合答案精度要求比较高的二分查找,有时与圆有关系时需要用到反三角函数利用 角度解题. 3.不好直接求解的一类计 ...

随机推荐

  1. zoj 3640 Help Me Escape 概率DP

    记忆化搜索+概率DP 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include ...

  2. eclipse运行hadoop程序报错:Connection refused: no further information

    eclipse运行hadoop程序报错:Connection refused: no further information log4j:WARN No appenders could be foun ...

  3. DX 绘制位图

    简单地学习了四个API: HRESULT CreateOffscreenPlainSurface( [in] UINT Width, // 宽度 [in] UINT Height, // 高度 [in ...

  4. devfs,proc,udev

    devfs:常用的驱动函数封装 proc:在用户态检查内核状态的机制 udev 和 devfs相比? 一个是用户空间里的,一个运行在内核空间且被2.6以后版本抛弃了

  5. java学习面向对象之匿名内部类

    之前我们提到“匿名”这个字眼的时候,是在学习new对象的时候,创建匿名对象的时候用到的,之所以说是匿名,是因为直接创建对象,而没有把这个对象赋值给某个值,才称之为匿名. 匿名对象回顾: class N ...

  6. poj2482Stars in Your Window(线段树+离散化+扫描线)

    http://poj.org/problem?id=2482 类似于上一篇 这题转化的比较巧妙 将一个点转化为一个矩形(x,y, x+w,y+h),扫描线入值为正 出值为负 也就是一根线过去 每进入一 ...

  7. Android反编译教程

    本文摘自 http://blog.csdn.net/ithomer/article/details/6727581 本文Android反编译教程,测试环境: Win7 Ultimate x64 Ubu ...

  8. asp mvc 路由

    public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Workflo ...

  9. bzoj1029

    贪心,比较明显了(很像USACO的风格); 按时间限制排序(升序) 顺次处理,如果当前时间能够修复就修复 否则就在之前修复的任务中找一个耗时最多(大于当前任务)的,改成修当前任务; 显然这样最优吧, ...

  10. 通用权限管理系统Ver2.0

    通用权限管理系统Ver2.0平台采用kendo+mvc4+Nhibernate技术实现,底层采用自定义ORM实现数据库底层代码,支持Oracle.SqlServer.mysql等常用数据库,界面采用k ...