【HDOJ6298】Maximum Multiple(数论)
题意:给定n,求x,y,z三个整数,使得x|n,y|n,z|n,且xyz最小
n<=1e6
思路:
不定方程1/x+1/y+1/z=1
只有(2,3,6)(2,4,4) (3,3,3)三组正整数解
设x<=y<=z,x=2或3
x=2时1/y+1/z=1/2,y=3或4时存在z
x=3时1/y+1/z=2/3,y=3时存在z
只有这三种情况
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int cas;
long long ans,n; int main()
{
// freopen("1001.in","r",stdin);
// freopen("1001.out","w",stdout);
scanf("%d",&cas);
for(int i=;i<=cas;i++)
{
scanf("%lld",&n);
ans=-;
if(!(n%)) ans=n/*n/*n/;
if(!(n%)) ans=n/*n/*n/;
if(!(n%)) ans=n/*n/*n/;
printf("%lld\n",ans);
}
return ;
}
【HDOJ6298】Maximum Multiple(数论)的更多相关文章
- hdu 6298 Maximum Multiple (简单数论)
Maximum Multiple Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 多校对抗赛 A Maximum Multiple
Maximum Multiple Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU6298 Maximum Multiple (多校第一场1001)
Maximum Multiple Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 6298 Maximum Multiple(规律)
hdu6298 Maximum Multiple 题目传送门 题意: 给你一个整数n,从中找出可以被n整除的三个数x,y,z: 要求x+y+z=n,且x*y*z最大. 思路: 开始一看T到1e6,n也 ...
- 数学--数论--HDU-2698 Maximum Multiple(规律)
Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y ...
- 数学--数论-- HDU6298 Maximum Multiple 打表找规律
Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y ...
- HDU_6298 Maximum Multiple 【找规律】
一.题目 Given an integer $n$, Chiaki would like to find three positive integers $x$, $y$ and $z$ such t ...
- 2018HDU多校训练一 A - Maximum Multiple
Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y ...
- 「日常训练」Maximum Multiple(HDU-6298)
题意与分析 一开始以为是一条高深的数学题,跳过去了,后来查其他题目的代码的时候无意看到,一看emmmmmm 稍微思考一下就有了.\(1=\frac{1}{3}+\frac{1}{3}+\frac{1} ...
随机推荐
- CF967D Resource Distribution
思路: 在一堆服务器中,资源最少的那一个是“瓶颈”,由此想到贪心思路. 首先对所有服务器按照资源数量c排序,再从头到尾扫描.对每个位置,根据x1和x2计算出两段连续的服务器集合分别分配给A任务和B任务 ...
- 【学习笔记】HTML position(static、fixed、relative、absolute)
[本文转载] position的四个属性值:static.fixed.relative.absolute 下面分别讲述这四个属性:<div id="parent"> ...
- 小程序canvas截图组件
最近做一个小程序的过程中,需要用到截图功能,网上搜了一下,发现没有符合要求的,就自己搞了个组件,方便复用. 目前功能很简单,传入宽高和图片路径即可,宽高是为了计算截图的比例,只支持缩放和移动. 实现思 ...
- 复位电路设计——利用PLL锁定信号(lock)产生复位信号
利用PLL锁定信号(lock)产生复位信号 在FPGA刚上电的时候,系统所需的时钟一般都要经过PLL倍频,在时钟锁定(即稳定输出)以前,整个系统应处于复位状态.因此,我们可以利用PLL的锁定信号来产生 ...
- swift的static和class修饰符---What is the difference between static func and class func in Swift?
Special Kinds of Methods Methods associated with a type rather than an instance of a type must be ma ...
- Django 你需要了解的入门操作
创建一个django project (我的版本是1.11.11) django-admin startproject mysite cd mysite 当前目录下会生成mysite的工程,目录结 ...
- CNN完成mnist数据集手写数字识别
# coding: utf-8 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data d ...
- MFC不同分辨率和缩放下正常显示的方法
方法1:为了满足Windows操作系统上不同分辨率下的显示,我们在OnPaint中重绘.
- C++友元函数和运算符重载
非成员友元函数.成员友元函数和友元类 1.友元的作用: (1)友元提供了不同类的成员函数之间.类的成员函数与一般函数之间进行了数据共享的机制: 2.友元的优点和缺点 优点:提高程序的运行效率: 缺点: ...
- spring中注解的实现原理
@Autowired和@Resource的区别: 在Java中使用@Autowired和@Resource注解进行装配,这两个注解分别是:1.@Autowired按照默认类型(类名称)装配依赖对象,默 ...