链接:

https://vjudge.net/problem/LightOJ-1116

题意:

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.

思路:

考虑,奇数*偶数不可能为奇数。

将n/2变成奇数即可。

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; int main()
{
int t, cnt = 0;
LL n, x;
scanf("%d", &t);
while(t--)
{
scanf("%lld", &n);
printf("Case %d: ", ++cnt);
if (n%2)
puts("Impossible");
else
{
LL tmp = n;
while(n%2==0)
n/=2;
printf("%lld %lld\n", n, tmp/n);
}
} 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. C - Ekka Dokka

    Ekka and his friend Dokka decided to buy a cake. They both love cakes and that's why they want to sh ...

  3. LightOJ Beginners Problems 部分题解

    相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's ...

  4. lightoj--1116--Ekka Dokka(水题)

    Ekka Dokka Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit Stat ...

  5. LightOJ 1058 - Parallelogram Counting 几何思维

    http://www.lightoj.com/volume_showproblem.php?problem=1058 题意:给你顶点,问能够成多少个平行四边形. 思路:开始想使用长度来扫描有多少根,但 ...

  6. Sigma Function (LightOJ - 1336)【简单数论】【算术基本定理】【思维】

    Sigma Function (LightOJ - 1336)[简单数论][算术基本定理][思维] 标签: 入门讲座题解 数论 题目描述 Sigma function is an interestin ...

  7. LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)

    http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS     M ...

  8. LightOJ 1278 - Sum of Consecutive Integers 分解奇因子 + 思维

    http://www.lightoj.com/volume_showproblem.php?problem=1278 题意:问一个数n能表示成几种连续整数相加的形式 如6=1+2+3,1种. 思路:先 ...

  9. lightoj 1105 - Fi Binary Number(dp+思维(斐波那契))

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1105 题解:这题你会巧妙的发现 1-(1),2-(10),3-(100),5- ...

随机推荐

  1. log4j向指定文件输出日志

    一.log4j.properties中的配置 log4j.logger.cache=INFO,ERROR,batchFile log4j.addivity.batchFile=false log4j. ...

  2. linux环境下编写shell脚本实现启动停止tomcat服务

    第一步:以管理员的身份进入控制台,在指定目录下新建一个shell脚本,我这里命名为tomcat.sh 第二步:编写shell脚本 #!/bin/bash tomcat_home=/usr/tomcat ...

  3. React项目使用Redux

    ⒈创建React项目 初始化一个React项目(TypeScript环境) ⒉React集成React-Router React项目使用React-Router ⒊React集成Redux Redux ...

  4. C++基础(静态数据成员和静态成员函数)

    [简介] 1.静态数据成员在类中声明,在源文件中定义并初始化: 2.静态成员函数没有this指针,只能访问静态数据成员: 3.调用静态成员函数:(1)对象.(2)直接调用: 4.静态成员函数的地址可用 ...

  5. STM32F103芯片SPI控制NRF24L012.4G无线模块交互通信实验

    1.NRF24L01模块的资料百度搜索一下就有很多.这里我就不做介绍本文主要侧重于应用层面实验介绍与分享. 2.先看下原理图. 根据原理图:写出NRF24L01  C语言驱动文件如下: #includ ...

  6. python学习-41 装饰器 -- 高阶函数

    装饰器:本质就是函数.是为其他函数添加附加功能的. 原则:1.不修改被修饰函数的源代码2.不修改被修饰函数的调用方式 --- 装饰器的知识储备 装饰器=高阶函数+函数嵌套+闭包 高阶函数 1.高阶函数 ...

  7. SQL——SELECT(查)

    一.SELECT语句的基本用法 SELECT语句会在数据库中选取数据,存放在一个结果表中. SELECT 语法: SELECT 列名1,列名2... FROM 表名: 先看一下student表: 1. ...

  8. 《C++语言程序设计》初学者必备教材

    很多刚开始学习C++语言的同学,都会遇到一个问题:很多教材都不适合零基础的初学者.它们有的枯燥乏味,让人难以消化吸收,有的层次结构混乱,很难理清楚知识点,有的更是难度太大,没有代码的过渡,就开始讲解算 ...

  9. ASP.NET Core依赖注入多个服务实现类

    依赖注入在 ASP.NET Core 中起中很重要的作用,也是一种高大上的编程思想,它的总体原则就是:俺要啥,你就给俺送啥过来. 服务类型的实例转由容器自动管理,无需我们在代码中显式处理. 因此,有了 ...

  10. windows下使用 fdfs_client 上传文件(转)

    https://www.cnblogs.com/kindleheart/p/10134502.html 注意:client = Fdfs_client(r"绝对路径"),一定要是绝 ...