Poj 1316 Self Numbers(水题)
一、Description
Kaprekar.) For example, d(75) = 75 + 7 + 5 = 87. Given any positive integer n as a starting point, you can construct the infinite increasing sequence of integers n, d(n), d(d(n)), d(d(d(n))), .... For example, if you start with 33, the next number is 33 +
3 + 3 = 39, the next is 39 + 3 + 9 = 51, the next is 51 + 5 + 1 = 57, and so you generate the sequence
33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, ...
The number n is called a generator of d(n). In the sequence above, 33 is a generator of 39, 39 is a generator of 51, 51 is a generator of 57, and so on. Some numbers have more than one generator: for example, 101 has two generators, 91 and 100. A number with
no generators is a self-number. There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.
Input
Output
二、题解
只做学习记录!
三、Java代码
public class Main {
public static void main(String[] args) {
boolean flag[]=new boolean[10001];
int t;
for(int i=1;i<10000;i++){
t=i+i/1000+(i % 1000)/100+(i % 100)/10+i % 10;
if(t>10000)
continue;
flag[t]=true;
}
for(int i=1;i<10000;i++){
if(flag[i]==false)
System.out.println(i);
}
}
}
Poj 1316 Self Numbers(水题)的更多相关文章
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
- poj 1002:487-3279(水题,提高题 / hash)
487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 236746 Accepted: 41288 Descr ...
- VK Cup 2016 - Qualification Round 2 A. Home Numbers 水题
A. Home Numbers 题目连接: http://www.codeforces.com/contest/638/problem/A Description The main street of ...
- poj 2105 IP Address(水题)
一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...
- POJ 3641 Oulipo KMP 水题
http://poj.org/problem?id=3461 直接KMP就好.水题 #include<cstdio> #include<cstring> const int M ...
- poj 1006:Biorhythms(水题,经典题,中国剩余定理)
Biorhythms Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 110991 Accepted: 34541 Des ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- poj 2000 Gold Coins(水题)
一.Description The king pays his loyal knight in gold coins. On the first day of his service, the kni ...
- POJ 1504 Adding Reversed Numbers (水题,高精度整数加法)
题意:给两个整数,求这两个数的反向数的和的反向数,和的末尾若为0,反向后则舍去即可.即若1200,反向数为21.题目给出的数据的末尾不会出现0,但是他们的和的末尾可能会出现0. #include &l ...
随机推荐
- android 多语言(在APP里面内切换语言)
创建SharedPreferences的管理类 public class PreferenceUtil { private static SharedPreferences mSharedPrefer ...
- ALV 表头 ADD_TEXT
[转自http://lz357502668.blog.163.com/blog/static/16496743201252891452493/] CALL METHOD valid_reference ...
- 坑爹的Hibernate 映射文件错误提示org.xml.sax.SAXParseException
今天整整一个上午都在和hibernate做斗争,早上一来,继续昨天的项目开发,发现spring项目不能启动,从错误中看是hibernate错误,多半是hibernate配置有错误,关键是错误提示中显示 ...
- java 死锁产生原因及解锁(转)
原文地址 进程死锁及解决办法 一.要点提示 (1) 掌握死锁的概念和产生死锁的根本原因. (2) 理解产生死锁的必要条件--以下四个条件同时具备:互斥条件.不可抢占条件.占有且申请条件.循环等待条件. ...
- php验证复选框的小例子
发布:thatboy 来源:Net [大 中 小] 本文介绍一个简单的php实例,通过代码验证复选框值的有效性,有需要的朋友,可以参考下. 验证复选框的php代码,如下: <?php ...
- ubuntu service XXX start启动报start: Rejected send message, 1 matche
service cron restart命令报错如下: stop: Rejected send message, 1 matched rules; type="method_call&quo ...
- rails json
respond_to do |f| f.json { render :json => {:a => b, :c => d}.to_json } } end
- Android selector背景选择器
selector根据不同的选定状态来定义不同的现实效果 常用属性: android:state_selected--------选中 android:state_focused--------获得焦点 ...
- 培训笔记——Linux历史
1. 计算机有分时与实时操作系统的区分,如Dos为实时操作系统,你只能给它下达一个命令,这个命令执行完了,你才能下达下一个命令:像Linux和我们用的Windows就是分时操作系统,特点是可以并发 ...
- 如何用<Enter>键代替<Tab>键实现光标焦点转移?
1.在主窗体的private中定义过程: procedure doenterastab(var Msg:TMsg;var Handled:Boolean); begin if Msg.messa ...