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- ...
随机推荐
- Java后台面试之java基础
经典类概念性问题 1.java支持的数据类型有哪些?什么是自动拆装箱? 12.Java有哪些特性,举个多态的例子. 14.请列举你所知道的Object类的方法. 15.重载和重写的区别?相同参数不同返 ...
- Golang_学习资料
个人推荐: http://godeye.org/index.php?a=course&id=6 http://mikespook.com/learning-go/ http://coolshe ...
- Docker 学习笔记(一):基础命令
仅为个人查阅使用,要学习 Docker 的话,推荐看这份文档:<Docker - 从入门到实践> P.S. 大多数的 docker container xxx/docker image x ...
- Java Embeded 包 与各个架构之间的关系
Oracle Java Embedded Suite 7.0 for Linux x86 V37917-01.zip Oracle Java Embedded Suite ...
- 音量调节条-封装通用的ProgressBar组件
import React, { Component } from 'react' import PropTypes from 'prop-types' import assign from 'obje ...
- 使用parted对Linux未分区部分进行分区
1. 使用命令parted -l 查看当前分区 可以看到硬盘有2396GB即有2.5T , 但是分区就分了50G一个盘, 需要分剩下部分 [root@localhost ~]# parted -l M ...
- js获取网页和屏幕高度
获取浏览器窗口的可视区域高度和宽度 document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象 ...
- Windows下的Android Studio环境搭建、安装使用
https://jingyan.baidu.com/article/20b68a88ff2ca4796cec6232.html https://blog.csdn.net/jklinux/articl ...
- Python-demo(抖音)
# -*- coding:utf-8 -*- from mitmproxy import ctx import json import requests import time import os p ...
- ASCII&UNICODE编码演化
ASCII 上个世纪60年代,美国制定了基于拉丁字母的一套电脑编码系统,取名为ASCII.它主要用于显示现代英语和其他西欧语言,是现今最通用的单字节编码系统. ASCII码使用指定的7位或8位二进制数 ...