ZR993
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的更多相关文章
随机推荐
- 在Struts2里面嵌入Spring
第一步:在web.xml中增加以下的listener <listener> <listener-class>org.springframework.web.context.Co ...
- yum方式安装MySQL【转】
在CentOS7中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB. 另外至2919年5月4号, 默认安装的my ...
- python 错误类型
- windows7蓝屏0x000000c4
故障还原: 360更新弹出更新提示,于是选择了关机自动更新,第二天开机发现电脑蓝屏报0x000000c4错误! 故障排查: 1.无法从最后一次正确配置启动windows7 2.无法进入安全模式 该错误 ...
- 初始化Redis密码
在配置文件/etc/redis/redis.conf中有个参数: requirepass 这个就是配置redis访问密码的参数: 比如 requirepass test123: (需重启Redis才能 ...
- Android 高仿微信语音聊天页面高斯模糊效果
目前的应用市场上,使用毛玻璃效果的APP随处可见,比如用过微信语音聊天的人可以发现,语音聊天页面就使用了高斯模糊效果. 先看下效果图: 仔细观察上图,我们可以发现,背景图以用户头像为模板,对其进行了高 ...
- 动态设置iframe高度
<%//动态设置iframe高度 %><script language="javascript" type="text/javascript" ...
- linux centos 一键安装环境
phpStudy for Linux 支持Apache/Nginx/Tengine/Lighttpd, 支持php5.2/5.3/5.4/5.5切换 已经在centos-6.5,debian-7.4. ...
- LOJ 10239 有趣的数列
LOJ 10239 有趣的数列 首先可以将奇数视作入栈,偶数视作出栈,那么它是卡特兰数,其实打表也能看出来,而且好像可以用dp? 不过这道题的难点不在这里,p不是素数,所以不能用求逆元来做,不过前50 ...
- ASCII代码表
>>ASCII代码表<<