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的更多相关文章
随机推荐
- 2019-11-12-WPF-添加窗口消息钩子方法
title author date CreateTime categories WPF 添加窗口消息钩子方法 lindexi 2019-11-12 18:46:53 +0800 2019-06-05 ...
- nodeJs学习-08 cookie、session
http-无状态的:两次访问之间,无区别,cookie可解决 cookie:在浏览器保存一些数据,每次请求都会带过来: 弊端:可以查看修改,并不安全.大小有限(4K) 读取--cookie-parse ...
- MUI - 解决动态列表页图片懒加载再次加载不成功的bug
首先描述一下功能 实现列表页动态加载 通过官方提供的"下拉刷新和上拉刷新"及"图片懒加载"示例实现. http://www.cnblogs.com/philly ...
- Nuxt.js打造旅游网站第2篇_首页开发
页面效果: 1.初始化默认布局 nuxtjs提供了一个公共布局组件layouts/default.vue,该布局组件默认作用于所有页面,所以我们可以在这里加上一些公共样式,在下一小结中还会导入公共组件 ...
- swap function & copy-and-swap idiom
在C++中,众所周知在一个资源管理类(例如含有指向堆内存的指针)中需要重新定义拷贝构造函数.赋值运算符以及析构函数(Big Three),在新标准下还可能需要定义移动构造函数和移动赋值运算符(Big ...
- poj 1085 Triangle War (状压+记忆化搜索)
Triangle War Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2685 Accepted: 1061 Desc ...
- hibernate 出现Caused by: java.sql.SQLException: Column 'id' not found.异常
用hibernate进行映射查询时,出现Caused by: java.sql.SQLException: Column 'id' not found 异常,检查数据库表及映射都有id且已经正确映射, ...
- POJ-3615_Cow Hurdles
Cow Hurdles Time Limit: 1000MS Memory Limit: 65536K Description Farmer John wants the cows to prepar ...
- qt 中创建一个工作线程(例子)
当一个事件需要很长的处理时间,就创建一个工作线程,防止主界面卡死. 1.新建一个QT的gui项目,里面包含main.cpp,mainwindow.h,mainwindow.cpp,mainwindow ...
- 逆序对(POJ2299 Ultra-QuickSort)
#include<bits/stdc++.h> using namespace std; int n; ],b[],ans;//a为待排序数组,b为临时数组,ans为逆序对数 void m ...