Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu

Submit
Status

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 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

3

10

5

12

Sample Output

Case 1: 5 2

Case 2: Impossible

Case 3: 3 4

Source

Problem Setter: Muhammad Rifayat Samee
Special Thanks: Jane Alam Jan

#include<cstdio>
#include<cstring>
int main()
{
int t,k=1;
long long w,n,m;
scanf("%d",&t);
while(t--)
{
scanf("%lld",&w);
if(w&1)
printf("Case %d: Impossible\n",k++);
else
{
for(m=2;m<=w;++m)
{
if(w%m==0&&((w/m)&1))
{
n=w/m;
break;
}
}
printf("Case %d: %lld %lld\n",k++,n,m);
}
}
return 0;
}

lightoj--1116--Ekka Dokka(水题)的更多相关文章

  1. light oj 1116 - Ekka Dokka

    1116 - Ekka Dokka   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Ekka ...

  2. LightOJ 1248 Dice (III) (水题,期望DP)

    题意:给出一个n面的色子,问看到每个面的投掷次数期望是多少. 析:这个题很水啊,就是他解释样例解释的太...我鄙视他,,,,, dp[i] 表示 已经看到 i 面的期望是多少,然后两种选择一种是看到新 ...

  3. lightoj 1020 (博弈水题)

    lightoj 1020 A Childhood Game 链接:http://lightoj.com/volume_showproblem.php?problem=1020 题意:一堆石子有 m 个 ...

  4. LightOJ 1023 Discovering Permutations 水题

    http://www.lightoj.com/volume_showproblem.php?problem=1023 题意:26字母全排列 思路:用next_permutation或者思维想一下都可以 ...

  5. 二分--LIGHTOJ 1088查找区间(水题)

    #include <iostream> #include <cstdio> #include <cmath> using namespace std; const ...

  6. LightOJ 1214 Large Division 水题

    java有大数模板 import java.util.Scanner; import java.math.*; public class Main { public static void main( ...

  7. LightOJ 1220 Mysterious Bacteria 水题

    暴力就行了,找出素因子,正的最多是30,然后负的最多是31(这一点wa了一次) #include <cstdio> #include <iostream> #include & ...

  8. lightoj 1010 (水题,找规律)

    lightoj 1010 Knights in Chessboard 链接:http://lightoj.com/volume_showproblem.php?problem=1010 题意:国际象棋 ...

  9. LightOJ 1166 Old Sorting 置换群 或 贪心 水题

    LINK 题意:给出1~n数字的排列,求变为递增有序的最小交换次数 思路:水题.数据给的很小怎么搞都可以.由于坐标和数字都是1~n,所以我使用置换群求循环节个数和长度的方法. /** @Date : ...

  10. LightOJ 1065 - Number Sequence 矩阵快速幂水题

    http://www.lightoj.com/volume_showproblem.php?problem=1065 题意:给出递推式f(0) = a, f(1) = b, f(n) = f(n - ...

随机推荐

  1. axios 使用post方式传递参数,后端接受不到问题

    一.URLSearchParams var params = new URLSearchParams(); params.append('key1', 'value1'); //你要传给后台的参数值 ...

  2. UVA 11248 Frequency Hopping

    Frequency Hopping Time Limit: 10000ms Memory Limit: 131072KB This problem will be judged on UVA. Ori ...

  3. ASP.NET-本地化、全球化

    在<system.web>中加入一个全球化的标识,网站就可以自适应全球化了 也可以将出错信息全球化 上面的这种方式测试过对google浏览器好像没用,但是对IE内核的是可行的,可能goog ...

  4. Qt之QPushButton

    简述 前面章节我们分享过Qt之QAbstractButton,讲解了QAbstractButton的基本用法,本节着重讲解QPushButton. 简述 常用状态 效果 源码 QSS 更多参考 关于Q ...

  5. 8、java高级面向对象-重载、构造器重载、初始化块、this、super、对象构造和初始化分析、覆盖、toString

    1.方法的重载(overload) 同一个类中同时存在一个以上的同名函数,参数个数或类型不同或顺序不同,称为方法的重载. 和返回值无关! 构造器重载:非默认构造器和默认构造器其实就是方法的重载. 2. ...

  6. 整合大量开源库项目(五)跳动的TextView JumpingBeans,良好体验的滚动条ConvenientBanner

    转载请注明出处:王亟亟的大牛之路 时间过得非常快,这一系列已经写了第五篇了(感觉还要写好久).今天又引入了2个非常好用的库JumpingBeans,ConvenientBanner.首先.先看一下效果 ...

  7. 【通信框架】Google的开源通信框架protobuf概述

    在阅读的过程中有不论什么问题,欢迎一起交流 邮箱:1494713801@qq.com    QQ:1494713801 一.作用 protobuf(Protocol Buffers)是Google内部 ...

  8. 小米净水器与小区过滤价格水对照.xls

    总结:要是一天用水量为7升下面.还是用小区的过滤水为好,合算. 假设过滤水需求量大,可能小米的净水器比較好.当然,小区的要天天去接.要求风雨无阻的. 这点小米的随用随接就更好. 注意一点,小米的还要用 ...

  9. asp.net的临时文件夹

    https://msdn.microsoft.com/en-us/library/ms366723.aspx Compilation Output   When your code is compil ...

  10. BZOJ 1379 模拟退火

    模拟退火的第一题~ //By SiriusRen #include <cmath> #include <cstdio> #include <algorithm> u ...