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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

思考题目,仔细检查,外加一个ceil函数

發(fā)布時間:2024/4/17 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 思考题目,仔细检查,外加一个ceil函数 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題目:

A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, the name “anna” is a palindrome. Numbers can also be palindromes (e.g. 151 or 753357). Additionally numbers can of course be ordered in size. The first few palindrome numbers are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, ... The number 10 is not a palindrome (even though you could write it as 010) but a zero as leading digit is not allowed.

Input

The input consists of a series of lines with each line containing one integer value i (1 ≤ i ≤ 2 ? 109 ). This integer value i indicates the index of the palindrome number that is to be written to the output, where index 1 stands for the first palindrome number (1), index 2 stands for the second palindrome number (2) and so on. The input is terminated by a line containing ‘0’.

Output

For each line of input (except the last one) exactly one line of output containing a single (decimal) integer value is to be produced. For each input value i the i-th palindrome number is to be written to the output.

Sample Input

1

12

24

0

Sample Output

1

33

151

這道題目就是要求你找出第n個回文序列數(shù)字,容易看出一位數(shù)的回文9種,二位數(shù)的回文9種,三位數(shù)的回文90種,四位數(shù)的回文90種,所以我們設(shè)一位數(shù)a[1]=9,a[2]=9后面就用一個函數(shù)得出來,a[i]=a[i-2]*10;規(guī)律容易,但是要想清楚怎么把一個個回文數(shù)字得出來,這題改bug改了兩個來小時,最后別人提醒我可能數(shù)組開小了,然后才過了,值得后面再做幾遍鍛煉邏輯能力

#include <bits/stdc++.h> using namespace std; long long a[20]; int b[20]; void value(){a[1]=9,a[2]=9;for(int i=3;i<=19;){a[i]=a[i-2]*10;a[i+1]=a[i-1]*10;i+=2;} } int main() {long long i,j,n,x,y,flag1,flag;value();while(cin>>n){if(n==0){break;}i=1,y=1;x=n;while(n>a[i]){n-=a[i];i++;}flag1=i;if((flag1)%2){flag=(flag1)/2+1;}else{flag=(flag1)/2;}b[1]=n*9/a[flag1];if((n*9)%a[flag1]){b[1]++;n-=(b[1]-1)*a[flag1]/9+1;}else{n-=(b[1]-1)*a[flag1]/9+1;}for(i=2;i<=flag;i++){y=1;for(j=2;j<=i;j++){y*=10;}b[i]=n/(a[flag1]/9/y)-1;if((n-(a[flag1]/9/y)*b[i])!=0){b[i]+=1;}n-=b[i]*(a[flag1]/9/y);}for(i=1;i<=flag;i++){cout<<b[i];}if(flag1%2){for(i=1;i<=flag-1;i++){cout<<b[flag-i];}}else{for(i=1;i<=flag;i++){cout<<b[flag-i+1];}}cout<<endl; }return 0; }

最后AC的感覺真爽

然后是一個ceil函數(shù),頭文件是#include<math.h>,這個函數(shù)感覺挺有用的,就是求一個數(shù),大于等于這個數(shù)的最小整數(shù)值。

附上一個水題目加深印象。

A square number is an integer number whose square root is also an integer. For example 1, 4, 81 are some square numbers. Given two numbers a and b you will have to find out how many square numbers are there between a and b (inclusive).

Input

The input file contains at most 201 lines of inputs. Each line contains two integers a and b (0 < a ≤ b ≤ 100000). Input is terminated by a line containing two zeroes. This line should not be processed.

Output

For each line of input produce one line of output. This line contains an integer which denotes how many square numbers are there between a and b (inclusive).

Sample Input

1?4

1?10

0?0

Sample Output

2

3

這題就是給你兩個數(shù),讓你求出兩個數(shù)之間有可以開出整數(shù)平方根的數(shù)目。

#include<iostream> #include<math.h> using namespace std; int main() {long long n,x,m,y;while(cin>>n>>m){if(n==0&&m==0){break;}x=ceil(sqrt(n));y=sqrt(m);cout<<y-x+1<<endl; } return 0; }

?

?

?

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

總結(jié)

以上是生活随笔為你收集整理的思考题目,仔细检查,外加一个ceil函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 精品在线观看一区 | 艳母日本动漫在线观看 | 无码精品人妻一区二区三区影院 | 国产美女白浆 | 精品国产一区二区三区av性色 | 男女黄色录像 | 欧美偷拍视频 | 亚洲激情免费 | 青青草狠狠操 | 激情综合网站 | 国产又粗又大又爽 | 97人妻精品一区二区三区免费 | 久久久久一区二区三区四区 | 一区精品视频在线观看 | 日批视频在线播放 | 人妻 日韩精品 中文字幕 | 福利在线免费 | 亲子伦视频一区二区三区 | 免费污片在线观看 | 亚洲一级一区 | 国产三级视频 | 久操视频免费在线观看 | 亚洲精品美女 | 人禽l交视频在线播放 视频 | 精品电影一区二区 | 竹菊影视一区二区三区 | 欧美亚洲影院 | 伊人网中文字幕 | 特级特黄aaaa免费看 | 国产精品久久福利 | 国产suv精品一区二区60 | 欧美在线黄 | 91久久精品在线 | 在线看片你懂的 | a级大片免费看 | 日韩一区二区影院 | 最新欧美大片 | 亚洲av无一区二区三区怡春院 | 国产亚洲精品久久久久丝瓜 | 聚色屋| 欧美三级视频在线观看 | 国产精品天天操 | 免费黄色国产 | 一极毛片 | 18禁肉肉无遮挡无码网站 | 久久中文字幕人妻熟av女蜜柚m | 亚洲一区二区三区婷婷 | 黄色不打码视频 | 国产视频资源 | 久久久久久av无码免费网站下载 | 亚洲国产精选 | 一级网站在线观看 | 国产偷拍一区二区三区 | 国产99自拍| 国产88av | 美女张开腿露出尿口 | 欧美卡一卡二卡三 | 神马久久久久久久久久久 | 日韩欧美国产成人 | 欧美午夜在线观看 | 亚洲一本在线 | 国产又大又粗又长 | 天天5g天天爽免费观看 | 女性裸体无遮挡胸 | 精品国产av鲁一鲁一区 | 欧美群交射精内射颜射潮喷 | 久久手机看片 | 久久yy | 亚洲天堂二区 | 精品人妻一区二区三区视频 | 成人av一区二区在线观看 | 亚洲乱码国产乱码精品精大量 | 青青草原国产视频 | 久久精品在线视频 | 5月婷婷6月丁香 | 中文字幕在线观看亚洲 | 国产av一区二区不卡 | 国产第一页在线观看 | 亚洲精品高清在线观看 | 成人精品在线 | 春闺艳妇(h)高h产乳 | 日韩网站免费 | 国产99爱| 香蕉视频免费网站 | 精产国品一区二区 | 国产精品视频全国免费观看 | 青青草免费公开视频 | 91精品国产日韩91久久久久久 | 色呦呦日韩精品 | 日韩激情精品 | 国产91av在线播放 | 九九少妇| 中出在线 | 日韩综合 | 99青草| www国产精品内射老熟女 | 久久久久久黄色片 | 国产精品一区二区三区久久久 | 亚洲性自拍 |