hnust 最小的x
问题 G: 最小的x
时间限制: 1 Sec 内存限制: 128 MB
提交: 2347 解决: 1155
[提交][状态][讨论版]
题目描述
TSQ对DK进行地狱式训练,找出满足下面公式的最小的x (0<x<1,000,000,000)
a,b,c,d 为已知的4个正整数。
s(x) 为x的各个位上的数字之和。
数学是DK的弱项,所以请你来帮忙解决这个问题。
输入
输入包含多组数据
每组数据包含四个数a,b,c,d (1≤a,b,c,d≤100)
输出
对于每组数据,输出x
如果没有符合条件的x,则输出no
每组数据占一行。
样例输入
10 4 9 4
1 1 1 1
1 2 3 4
样例输出
24000
1048576
no
提示
样例1:
a=10,b=4,c=9,d=4
最小x=24000;则有s(x)=2+4+0+0+0=6, 满足24000=(6+10)*(6+4)*(6+9)*(6+4) , 所以答案为24000
#include <cstdio>
int boss(int n)
{
int ans=;
while(n)
{
ans+=n%;
n/=;
}
return ans;
}
int main()
{
int a,b,c,d,flag;
while(~scanf("%d%d%d%d",&a,&b,&c,&d))
{
flag=;
for(int i=;i<;i++)
{
if(boss((i+a)*(i+b)*(i+c)*(i+d))==i)
{
printf("%d\n",(i+a)*(i+b)*(i+c)*(i+d));
flag=;
break;
}
}
if(flag) printf("no\n");
}
return ;
}
hnust 最小的x的更多相关文章
- BZOJ 1391: [Ceoi2008]order [最小割]
1391: [Ceoi2008]order Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1509 Solved: 460[Submit][Statu ...
- 《徐徐道来话Java》:PriorityQueue和最小堆
在讲解PriorityQueue之前,需要先熟悉一个有序数据结构:最小堆. 最小堆是一种经过排序的完全二叉树,其中任一非终端节点数值均不大于其左孩子和右孩子节点的值. 可以得出结论,如果一棵二叉树满足 ...
- C++ 最小化到托盘
#define WM_SHOWTASK (WM_USER + 1) void CTestDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID &a ...
- nw.js自定义最小化图标的click事件
选择frameless时,最小化和关闭按钮的点击事件需要自己来做,办法是: /* * 下面两个模块一定要引入到js文件中 */ var gui = require('nw.gui'); var win ...
- AC日记——最小的N个和 codevs 1245
1245 最小的N个和 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 查看运行结果 题目描述 Description 有两个长度为 N ...
- POJ 2125 Destroying the Graph 二分图最小点权覆盖
Destroying The Graph Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8198 Accepted: 2 ...
- codevs 1245 最小的N个和
1245 最小的N个和 http://codevs.cn/problem/1245/ 题目描述 Description 有两个长度为 N 的序列 A 和 B,在 A 和 B 中各任取一个数可以得到 N ...
- [原]CentOS7.2最小安装环境部署Asp.NET Core笔记
转载请注明原作者(think8848)和出处(http://think8848.cnblogs.com) 写在前面的话 不知不觉在cnblogs上注册已经10多年了,看我的园龄就直接暴露了我实际年龄, ...
- [LeetCode] Find K Pairs with Smallest Sums 找和最小的K对数字
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define ...
随机推荐
- C#使用事件方式Winform窗体之间传值
[摘自:http://www.cnblogs.com/codeToUp/p/5371062.html] 工程的源代码地址:https://github.com/yes-or-no/WinFormTra ...
- 1、webpack安装
1.局部安装: npm i -D (npm install --save-dev的简写) 安装指定版本:npm i -D webpack @version 安装最新版:npm i -D webpack ...
- typeid操作符
typeid() operator返回type_info,返回值不可拷贝.不可赋值 // Illustrates the typeid operator. #include <iostream& ...
- python中的zipfile
zipfile - Work with ZIP archives ZipFile.namelist() Return a list of archive members by name. 返回压缩成员 ...
- 深入浅出:promise的各种用法
https://mp.weixin.qq.com/s?__biz=MzAwNTAzMjcxNg==&mid=2651425195&idx=1&sn=eed6bea35323c7 ...
- 使用winsw将spring-boot jar包注册成windows服务
背景:最近的项目中使用spring-boot, https://github.com/kohsuke/winsw/releases <service> <id>YJPSS< ...
- floyed dij spfa 模板
/* SPFA模板 */ const int inf=0x3f3f3f3f; inline int SPFA(int s){ memset(dis,inf,sizeof(dis)); queue< ...
- Thymeleaf显示Map集合数据
<select class="form-control zz-set-input-size" id="channel"> <option va ...
- C#基础-面向对象-封装
封装 命名空间 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApp6 { c ...
- list推导式,dict推导式,set推导式
生成一个1-14的列表 1.1 普通for循环 # lst = [] # for i in range(1,15): # lst.append(i) # print(lst) # # 结果: # [1 ...