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 ...
随机推荐
- hdu2492树状数组
题目链接:http://icpc.njust.edu.cn/Problem/Hdu/2492/ 题目大意:给定一个序列,求长度为三的子序列(a,b,c)使得a<b<c或a>b> ...
- 在vscode中配置LeetCode插件,从此愉快地刷题
大家好,今早在B站看到up主的vscode里藏了leetcode插件,这才知道原来还有这款神器.但是没想到在用的时候遇到了一些麻烦,花了一点时间才解决.所以写这篇文章除了给大家安利这个好用的插件之外, ...
- 从SqlSessionFactoryBean的引用浅谈spring两种bean模式
mybatis是以一个 SqlSessionFactory 的实例为中心的.SqlSessionFactory可以通过SqlSessionFactoryBuilder获得实例.使用mybatis-sp ...
- Hive架构原理
什么是Hive Hive是由Facebook开源用于解决海量结构化日志的数据统计:Hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射 成一张表,并提供类SQL查询功能,底层计算引 ...
- [SQL]511+512+534+550+569
511. 游戏玩法分析 I solution SELECT player_id, MIN(event_date) AS first_login FROM Activity GROUP BY playe ...
- 详解十大经典机器学习算法——EM算法
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是机器学习专题的第14篇文章,我们来聊聊大名鼎鼎的EM算法. EM算法的英文全称是Expectation-maximization al ...
- [LeetCode] 936. Stamping The Sequence 戳印序列
You want to form a `target` string of lowercase letters. At the beginning, your sequence is target.l ...
- OpenCV-Python 直方图-4:直方图反投影 | 二十九
目标 在本章中,我们将学习直方图反投影. 理论 这是由Michael J. Swain和Dana H. Ballard在他们的论文<通过颜色直方图索引>中提出的. 用简单的话说是什么意思? ...
- 【Ubuntu】常用命令汇总,整理ing
Ubuntu 常用命令(在此页面中Ctrl+F即可快速查找) 在Ubuntu系统使用过程中,会不断地接触到命令行操作,下面对一些常用的命令进行汇总,方便查找. 1.文件操作 1.1 文件复制拷贝 cp ...
- Java多线程工具类之循环栅栏计数器
Java多线程下循环计数器 本文主要内容:CyclicBarrier(下文中凯哥就用cycBar来代替)定义介绍:举例说明:代码演示:从源码来看原理及总结:CyclicBarrier与CountDow ...