light oj 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的更多相关文章
- Light OJ 1116
基础数学:.. #include<bits/stdc++.h> using namespace std; typedef unsigned long long ULL; int main( ...
- Light OJ 1114 Easily Readable 字典树
题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 ...
- Light OJ 1429 Assassin`s Creed (II) BFS+缩点+最小路径覆盖
题目来源:Light OJ 1429 Assassin`s Creed (II) 题意:最少几个人走全然图 能够反复走 有向图 思路:假设是DAG图而且每一个点不能反复走 那么就是裸的最小路径覆盖 如 ...
- Light OJ 1406 Assassin`s Creed 减少国家DP+支撑点甚至通缩+最小路径覆盖
标题来源:problem=1406">Light OJ 1406 Assassin`s Creed 意甲冠军:向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路: ...
- Light OJ 1316 A Wedding Party 最短路+状态压缩DP
题目来源:Light OJ 1316 1316 - A Wedding Party 题意:和HDU 4284 差点儿相同 有一些商店 从起点到终点在走过尽量多商店的情况下求最短路 思路:首先预处理每两 ...
- light oj 1007 Mathematically Hard (欧拉函数)
题目地址:light oj 1007 第一发欧拉函数. 欧拉函数重要性质: 设a为N的质因数.若(N % a == 0 && (N / a) % a == 0) 则有E(N)=E(N ...
- Light OJ 1406 Assassin`s Creed 状态压缩DP+强连通缩点+最小路径覆盖
题目来源:Light OJ 1406 Assassin`s Creed 题意:有向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路:最少的的人能够走全然图 明显是最小路径覆盖问题 ...
- Light OJ 1288 Subsets Forming Perfect Squares 高斯消元求矩阵的秩
题目来源:Light OJ 1288 Subsets Forming Perfect Squares 题意:给你n个数 选出一些数 他们的乘积是全然平方数 求有多少种方案 思路:每一个数分解因子 每隔 ...
- Jan's light oj 01--二分搜索篇
碰到的一般题型:1.准确值二分查找,或者三分查找(类似二次函数的模型). 2.与计算几何相结合答案精度要求比较高的二分查找,有时与圆有关系时需要用到反三角函数利用 角度解题. 3.不好直接求解的一类计 ...
随机推荐
- jmeter 测试java协议经验总结
对java协议的良好支持,是jmeter比loadrunner优秀的地方,但是坑也不少,本文将相关点都整理下来备忘 一. 依赖的jar包 使用IDE开发jemter java协议脚本时,需要导入以下几 ...
- Android studio 下的 NDK 配置方法和注意事项
http://blog.csdn.net/u013598660/article/details/47341963
- NFC(10)NDEF uri格式规范及读写示例(解析与封装ndef uri)
只有遵守NDEF uri 格式规范的数据才能写到nfc标签上. NDEF uri 格式规范 uri 只有两部分: 第1个字节是uri协议映射值,如:0x01 表示uri以 http://www.开头. ...
- NFC(5)编写NFC程序的基本步骤
1,设置权限 <uses-permission android:name="android.permission.NFC" /> 2,限制Android版本 <u ...
- 基于邻接矩阵的广度优先搜索遍历(BFS)
题目:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2141&cid=1186 #include<stdio.h> #incl ...
- PHP分次读取xls
<?php $sourceFile = "1.tmp"; //要下载的临时文件名 $outFile = "用户订单.xls"; //下载保存到客户端的文件 ...
- Fiddler的基本介绍
fiddler 简介: 一款免费且功能强大的数据包抓取软件.它通过代理的方式获取程序http通讯的数据,可以用其检测网页和服务器的交互情况,能够记录所有客户端和服务器间的http请求,支持监视.设置断 ...
- Hibernate4.x之入门篇
Hibernate作为一个优秀的持久化框架.ORM框架.在日常的Java开发中常常用到.本文主要通过一个简单的例子来介绍下Hibernate4.x的入门知识. 新建一个Java项目,并加入Hibern ...
- 使用CSS3美化复选框checkbox
我们知道HTML默认的复选框样式十分简陋,而以图片代替复选框的美化方式会给页面表单的处理带来麻烦,那么本文将结合实例带您一起了解一下使用CSS3将复选框checkbox进行样式美化,并且带上超酷的滑动 ...
- ASP.NET MVC 基础
ASP.NET MVC oo1 Mvc准备工作课程安排:ORM->AspNet MVC开发环境:VS2012/VS2013SqlServer2008/2005主讲Asp.Net Mvc4 Raz ...