日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

        歡迎訪問 生活随笔!

        生活随笔

        當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

        编程问答

        poj1316

        發(fā)布時間:2023/12/13 编程问答 39 豆豆
        生活随笔 收集整理的這篇文章主要介紹了 poj1316 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

        1.鏈接地址

        ?????https://vjudge.net/problem/POJ-1316

        2.問題描述

        ?In 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any positive integer n, define d(n) to be n plus the sum of the digits of n. (The d stands for digitadition, a term coined by 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.?

        輸入樣例

        ?None

        輸出樣例

        1 3 5 7 9 20 31 42 53 64|| <-- a lot more numbers| 9903 9914 9925 9927 9938 9949 9960 9971 9982 9993

        3.解題思路

        ?采取了打表后再判斷的方法,不過在另一篇題解發(fā)現(xiàn)了一種數(shù)學解的方法,還沒看太懂先po上來再研究看看https://blog.csdn.net/xinghongduo/article/details/5805240

        4.算法實現(xiàn)源代碼

        #include<iostream> #include<cstring> using namespace std;int main() {int num[10001];int i,j,k,m;memset(num,0,sizeof(num));for( i= 0;i < 10; i++){for(j = 0;j < 10; j++){for(k = 0;k < 10; k++){for(m = 0;m < 10; m++){if((i+j+k+m+i*1000+j*100+k*10+m) < 10000)num[i+j+k+m+i*1000+j*100+k*10+m] = 1;}}}}for(i = 1;i < 10000;i++)if(num[i] == 0)printf("%d\n",i); }

        ?

        轉(zhuǎn)載于:https://www.cnblogs.com/KasenBob/p/11163601.html

        總結(jié)

        以上是生活随笔為你收集整理的poj1316的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

        如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。