C - Ekka Dokka
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 Nsquare 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
题目大意:就是判断一个数是否可以分解为一个奇数和一个偶数的乘积,并且使偶数最小
题解 先判断如果是奇数的话,直接输出impossible ,因为他不可能存在偶数因子,对于偶数,首先2是一个因子,然后循环除以2直到原数字变成了奇数就可以了
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
int main(){
int t;
scanf("%d",&t);
for(int i=;i<=t;i++){
ll x;
scanf("%lld",&x); if(x&) {
printf("Case %d: Impossible\n",i);
} else {
ll ans=,t=;
while(x%==){
x=x/;
ans*=;
}
printf("Case %d: %lld %lld\n",i,x,ans);
}
}
return ;
}
C - Ekka Dokka的更多相关文章
- light oj 1116 - Ekka Dokka
1116 - Ekka Dokka PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Ekka ...
- lightoj--1116--Ekka Dokka(水题)
Ekka Dokka Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Stat ...
- LightOJ Beginners Problems 部分题解
相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's ...
- LightOJ - 1116-Ekka Dokka(思维)
链接: https://vjudge.net/problem/LightOJ-1116 题意: Ekka and his friend Dokka decided to buy a cake. The ...
- spring-framework源码编译及导入
环境说明: 时间:2017-09-26 OS name: "mac os x", version: "10.12.4", arch: "x86_64& ...
- Spring5源码解析-前奏:本地构建Spring5源码
构建环境 macOS 10.13.6 JDK1.8 IntelliJ IDEA 2018.3.6 (Ultimate Edition) Spring v5.1.9.RELEASE Gradle 5.5 ...
- 学习Spring5源码时所遇到的坑
学习Spring5源码时所遇到的坑 0)本人下载的源码版本是 spring-framework-5.0.2.RELEASE 配置好gradle环境变量之后,cmd进入到spring项目,执行gradl ...
- MQTT研究之EMQ:【EMQX使用中的一些问题记录(3)】
EMQX功能强大,但是帮助信息或者可用资料的确有限,遇到个问题,比较难找到处理的头绪,今天,我要记录的是,使用中出现EMQX宕机,但是呢,启动也启动不了. 今天记录的内容,就以操作EMQX 3.2.3 ...
- intellij idea gradle 导入 spring 问题记录
环境: windows 7 oracle jdk 1.8 intellij idea 2019.3.1 spring-framework 5.1.22.RELEASE 步骤: 1: 下载解压sprin ...
随机推荐
- 洛谷 P1047 校门外的树 题解
Case 1. 本题其实不难,直接模拟就可以了.时间复杂度: \(O(L \times M)\) Case 2. 考虑一个简单的增强:把原来的: \[L \leq 10^4,M \leq 10^2 \ ...
- [概率] HDU 2019 Multi-University Training Contest 10 - Valentine's Day
Valentine's Day Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others ...
- dirname,basename的用法与用途
#dirname介绍 当对文件使用dirname时,返回文件的上级目录,输出是否是绝对路径取决于输入的文件名是绝对路径 如果对目录使用,则返回上级目录 basename命令与dirname相反,读取文 ...
- 知识图谱里的知识存储:neo4j的介绍和使用
一般情况下,我们使用数据库查找事物间的联系的时候,只需要短程关系的查询(两层以内的关联).当需要进行更长程的,更广范围的关系查询时,就需要图数据库的功能. 而随着社交.电商.金融.零售.物联网等行 ...
- NeurIPS审稿引发吐槽大会,落选者把荒唐意见怼了个遍:“我谢谢你们了”
七月份的尾巴,机器学习顶会NeurIPS 2019的初步结果已经来了. 一年一度的吐槽盛会也由此开始. "有评审问我啥是ResNet." "有评审问我为啥没引用X论文.我 ...
- jmeter响应乱码(十四)
方法一: jmeter响应乱码解决方法:在jmeter的bin目录下找到jmeter.propertis这个文件,修改里面的#sampleresult.default.encoding=ISO-885 ...
- 骑士cms-通读全文-代码审计
版本号:3.5.1 下载地址:http://103.45.101.75:66/2/201412/74cms.rar 1.审计方法 通读审计 1.1查看文件结构 首先需要看看有哪些文件和文件夹,寻找名称 ...
- ConcurrentHashMap1.7和1.8的源码分析比较
ConcurrentHashMap 在多线程环境下,使用HashMap进行put操作时存在丢失数据的情况,为了避免这种bug的隐患,强烈建议使用ConcurrentHashMap代替HashMap,为 ...
- cat userlist
cat命令 Linux下的一个文本输出命令,通常用于观看某个文件的内容 功能: 1.一次显示整个文件 $ cat filename 2.从键盘创建一个文件 $ cat > filename 只能 ...
- MyBatis 教程 ——检视阅读
MyBatis 教程 --检视阅读 准备 官网文档-中文 教程地址yiibai,质量很差 教程地址w3cschool,纯理论,还不如直接看官网文档 教程地址Mybatis框架入门教程,Oracle M ...