ZR993

首先,这种和平方有关的,首先应当考虑根号做法

这道题目,我们可以直接暴力\(\log_{10}w + 10\)判断一个数是否能够由原数变化的到

直接\(O(\sqrt{n})\)枚举所有的平方数,直接暴力上面的方法check

#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<map>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const int N = 55;
const LL INF = 1e13;
LL n;
int s[N];
int num[11];
int num2[11];
int h[N];
inline LL read(){
LL v = 0,c = 1;char ch = getchar();
while(!isdigit(ch)){
if(ch == '-') c = -1;
ch = getchar();
}
while(isdigit(ch)){
v = v * 10 + ch - 48;
ch = getchar();
}
return v * c;
}
inline bool work(LL x){
memset(num2,0,sizeof(num2));
if(x == 0) num2[0]++;
while(x){
num2[x % 10]++;
x /= 10;
}
for(int i = 0;i < 10;++i) if(num2[i] > num[i]) return 0;
return 1;
}
int main(){
n = read();
while(n){
memset(num,0,sizeof(num));
LL g = n;int t = 0;
while(g){
h[++t] = g % 10;
num[g % 10]++;
g /= 10;
}
sort(h + 1,h + t + 1);
LL to = 1;
for(int i = t;i >= 1;--i) to = to * 10 + h[i];
for(LL i = 0;1ll * i * i <= to;++i){
if(work(i) && work(i * i))
printf("%lld * %lld = %lld\n",i,i,1ll * i * i);
}
n = read();
}
return 0;
}

ZR993的更多相关文章

随机推荐

  1. thinkphp5.0 验证提示信息的类型

    以上是5.0.12版本 下面是5.0.5版本,没有elseif 上图中红方格的值只能是string类型,但是这种情况是在5.0.5版本是可以设置为array类型的

  2. 详解composer的自动加载机制

    composer是一个用PHP开发的用来管理项目依赖的工具,当你在项目中声明了依赖关系后,composer可以自动帮你下载和安装这些依赖库,并实现自动加载代码. 安装composer composer ...

  3. 【C++】为什么INT_MIN不是直接写成-2147483648(转载)

    最近在编程中遇到一个问题: #include <iostream> using namespace std; int main() { int n = -2147483648; //cou ...

  4. Kubernetes1.3新特性:支持GPU

    (一)  背景资料 GPU就是图形处理器,是Graphics Processing Unit的缩写.电脑显示器上显示的图像,在显示在显示器上之前,要经过一些列处理,这个过程有个专有的名词叫" ...

  5. MaxCompute 图计算开发指南

    快速入门step by step MaxCompute Studio 创建完成 MaxCompute Java Module后,即可以开始开发Graph了. 代码示例 在examples目录下有gra ...

  6. 域名拆分 tld

    概念 URL Universal Resource Locator ,统一资源定位符. 用处:用来标识互联网资源的唯一地址. 本质:提供了互联网上任一资源地址的通用表示方法. protocol://h ...

  7. Java练习 SDUT-1211_英文金曲大赛

    英文金曲大赛 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 我们在"渊子数"的题目中已经了解了渊子 ...

  8. git错误——Eclipse git commit错误;Committing changes has encountered a problem An Internal error occured

    背景 在使用eclipse时,使用git commit 提交代码时,出项如下错误 解决方法 在工程目录下找到 .git 文件夹 ,找到里面的 index.lock 文件,然后删掉这个文件就可以了,如下 ...

  9. 【BestCoder Round #93 1004】MG loves set

    [题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=6022 [题意] 让你求一个集合的子集数目; 这个子集有要求; 即: 它所有元素的平方的和小于它所有 ...

  10. H3C PPP MP配置示例三