LightOJ - 1116-Ekka Dokka(思维)
链接:
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(思维)的更多相关文章
- light oj 1116 - Ekka Dokka
1116 - Ekka Dokka PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Ekka ...
- 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 ...
- LightOJ Beginners Problems 部分题解
相关代码请戳 https://coding.net/u/tiny656/p/LightOJ/git 1006 Hex-a-bonacci. 用数组模拟记录结果,注意取模 1008 Fibsieve's ...
- lightoj--1116--Ekka Dokka(水题)
Ekka Dokka Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Stat ...
- LightOJ 1058 - Parallelogram Counting 几何思维
http://www.lightoj.com/volume_showproblem.php?problem=1058 题意:给你顶点,问能够成多少个平行四边形. 思路:开始想使用长度来扫描有多少根,但 ...
- Sigma Function (LightOJ - 1336)【简单数论】【算术基本定理】【思维】
Sigma Function (LightOJ - 1336)[简单数论][算术基本定理][思维] 标签: 入门讲座题解 数论 题目描述 Sigma function is an interestin ...
- LightOJ 1138 Trailing Zeroes (III)(二分 + 思维)
http://lightoj.com/volume_showproblem.php?problem=1138 Trailing Zeroes (III) Time Limit:2000MS M ...
- LightOJ 1278 - Sum of Consecutive Integers 分解奇因子 + 思维
http://www.lightoj.com/volume_showproblem.php?problem=1278 题意:问一个数n能表示成几种连续整数相加的形式 如6=1+2+3,1种. 思路:先 ...
- lightoj 1105 - Fi Binary Number(dp+思维(斐波那契))
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1105 题解:这题你会巧妙的发现 1-(1),2-(10),3-(100),5- ...
随机推荐
- [转帖]TPC-C基准测试之链路层优化
TPC-C基准测试之链路层优化 阿里数据库 6000万 TPMC的测试结构. http://www.itpub.net/2019/10/14/3436/ 作者:易鸿伟 闫建良 王光树 在 TPC-C ...
- SQLServer分页查询方法整理以及批量插入操作SqlBulkCopy
分页查询 通用方法:sqlserver 2005 + ROW_NUMBER() OVER()方式: ; TOP NOT IN方式 : ID FROM TripDetail ORDER BY ID) O ...
- java实现邮箱发送邮件功能
邮箱验证是一个很常见的功能了,基本上每个网站都会用的到,java也有专门的jar来处理邮件发送等服务,这里只是简单的实现一下发送邮件的功能,具体jar包就不再提供了,我会把所有需要引用的包都贴出来,方 ...
- 修改织梦DedeCMS投票漏洞
织梦/dedecms系统我们都知道是有很多漏洞的,我在调试投票功能的时候正好要用到投票功能,这不就出现了漏洞,下面我就给大家展示如何修复这个织梦投票漏洞 首先我们打开//dedevote.class. ...
- OpenCV学习笔记3
OpenCV学习笔记3 图像平滑(低通滤波) 使用低通滤波器可以达到图像模糊的目的.这对与去除噪音很有帮助.其实就是去除图像中的高频成分(比如:噪音,边界).所以边界也会被模糊一点.(当然,也有一些模 ...
- 暑期ACM集训
2019-07-17 08:42:11 这是总结昨天的做题情况 总体来说,好久的没做题了,实力下降了许多,这一个月假又学习吧!!!! A - Ropewalkers Polycarp decided ...
- nodejs模块fs——文件操作api
// fs模块常用api // 读取文件 .写入文件 .追加文件. 拷贝文件 .删除文件 // 读取文件 // fs.readFile(path[, options], callback) // fs ...
- PAT-1030 Travel Plan (30 分) 最短路最小边权 堆优化dijkstra+DFS
PAT 1030 最短路最小边权 堆优化dijkstra+DFS 1030 Travel Plan (30 分) A traveler's map gives the distances betwee ...
- RabbitMQ集群部署、高可用和持久化
RabbitMQ 安装和使用 1.安装依赖环境 在 http://www.rabbitmq.com/which-erlang.html 页面查看安装rabbitmq需要安装erlang对应的版本 在 ...
- Asp.netCore 的Startup 不继承接口
有一个问题: Asp.netCore 的Startup 要实现 Config 和ConfigServie 方法, 为什么不接口约束呢. 进入源码: // // 摘要: // /// Specify t ...