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的更多相关文章
随机推荐
- SiteMesh:一个优于Apache Tiles的Web页面布局、装饰框架
一.SiteMesh项目简介 OS(OpenSymphony)的SiteMesh是一个用来在JSP中实现页面布局和装饰(layout and decoration)的框架组件,能够帮助网站开发人员较容 ...
- Spring → 01:概述
一.了解Spring发展 Spring是一个开源框架,Spring是于2003年兴起的一个轻量级的Java开发框架,由Rod Johnson在其著作Expert One-On-One J2EE Dev ...
- day16 web前端之JavaScript
页面布局补充 样例页面: 示例代码: <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- 解决PowerDesigner中DBMS选项卡为空白
点击DBMS后面的黄色(浏览)文件图标, 找到安装目录里面PowerDesigner \Resource Files\DBMS,就可以了.
- 【NS2】cygwin+NS2.29安装之道 (转载)
最近接了一个需要进行网络模拟的项目.对与网络模拟一窍不通的本人算是一个挑战.于是乎开始整日上网搜索相关的资料,没想到这个世界的资源真是丰富多彩.最后发现了一个网络模拟的流行软件NS2,在经过多次尝试后 ...
- LeetCode115 Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S. (Hard) A subse ...
- @总结 - 2@ 位运算卷积/子集卷积 —— FWT/FMT
目录 @0 - 参考资料@ @1 - 异或卷积概念及性质@ @2 - 快速沃尔什正变换(异或)@ @3 - 快速沃尔什逆变换(异或)@ @4 - 与卷积.或卷积@ @5 - 参考代码实现@ @6 - ...
- 洛谷 2149 [SDOI2009]Elaxia的路线
题目描述 最近,Elaxia和w的关系特别好,他们很想整天在一起,但是大学的学习太紧张了,他们 必须合理地安排两个人在一起的时间.Elaxia和w每天都要奔波于宿舍和实验室之间,他们 希望在节约时间的 ...
- 模板—e-dcc缩点
int dfn[MAXN],low[MAXN],cnt; bool isbridge[MAXN]; void tarjan(int x,int edg) { low[x]=dfn[x]=++cnt; ...
- mysql数据库之表和库
SQL:语句主要用于存储数据,查询数据,更新数据和管理关系数据库系统SQL语言有IBM开发,sql语言分为中类型: 1.DDL语句 数据库定义语句:数据库,表,视图,索引,存储过程,例如create, ...