Poj 1142 Smith Numbers
2013-05-16 09:38
274 查看
暴力
1WA于因数唯一的smith数处理
2Y
1WA于因数唯一的smith数处理
2Y
#include<stdio.h> #include<stdlib.h> int count(int y){ int res=0,tp=y; while(y){ res+=y%10;y/=10; } return res; } bool Smith(int x){ int left=count(x); int i,right=0; int tp=x; for(i=2;i*i<=tp;i++){ while(x%i==0){ right+=count(i); x/=i; } } if(!right)return 0; if(x-1)right+=count(x); return left==right; } int main(){ int n; while(scanf("%d",&n)!=EOF&&n){ while(n++){ if(Smith(n)){ printf("%d\n",n); break; } } } return 0; }
相关文章推荐
- poj 1142——Smith Numbers
- POJ1142 Smith Numbers(分治法)
- POJ-----1142---Smith Numbers
- 分解质因数——Poj 1142 Smith Numbers
- poj 1142 Smith Numbers 【容斥原理】
- POJ1142——Smith Numbers
- POJ 1142 Smith Numbers 笔记
- poj 1142 Smith Numbers 筛法
- poj 1142 Smith Numbers
- POJ 1142 Smith Numbers(我不管,水题我也要写博客)
- POJ - 1142 Smith Numbers 分治 分解质因子
- ZOJ 1133 & POJ 1142 Smith Numbers
- POJ 1142 Smith Numbers
- POJ-1142 & HDOJ-1333 Smith Numbers 解题报告
- zoj 1133 || poj 1142 Smith Numbers
- poj 1142 Smith Numbers
- POJ1142 Smith Numbers(数论,分治+暴力,质因数分解)
- 【POJ】1142 - Smith Numbers(容斥原理)
- POJ 1142 Smith Numbers
- poj1142 Smith Numbers