統計0-n數字中出現k的次數

/*** 統計0-n數字中出現k的次數,其中k范圍為0-9
*/
public static int countOne(int k, int n) {if (k > n) {return 0;}int sum = 0;int right = 0;for (int i = 0; n > 0; i++) {int last = n % 10;sum += last * i * (int) Math.pow(10, i - 1);if (k == 0) {sum -= (int) Math.pow(10, i);}if (last > k) {sum += (int) Math.pow(10, i);}if (last == k) {sum += right + 1;}right += last * Math.pow(10, i);n /= 10;}return sum + (0 == k ? 1 : 0);}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389324.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389324.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389324.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

房價預測 search Search 中對數據預處理的學習

對于缺失的數據: 我們對連續數值的特征做標準化(standardization):設該特征在整個數據集上的均值為 μ ,標準差為 σ 。那么,我們可以將該特征的每個值先減去 μ 再除以 σ 得到標準化后的每個特征值。對于…

3.6.1.非阻塞IO

本節講解什么是非阻塞IO,如何將文件描述符修改為非阻塞式 3.6.1.1、阻塞與非阻塞 (1)阻塞是指函數調用會被阻塞。本質是當前進程調用了函數,進入內核里面去后,因為當前進程的執行條件不滿足,內核無法里面完…

rstudio 管道符號_R中的管道指南

rstudio 管道符號R基礎知識 (R Fundamentals) Data analysis often involves many steps. A typical journey from raw data to results might involve filtering cases, transforming values, summarising data, and then running a statistical test. But how can we link al…

蒙特卡洛模擬預測股票_使用蒙特卡洛模擬來預測極端天氣事件

蒙特卡洛模擬預測股票In a previous article, I outlined the limitations of conventional time series models such as ARIMA when it comes to forecasting extreme temperature values, which in and of themselves are outliers in the time series.在上一篇文章中 &#…

iOS之UITraitCollection

UITraitCollection 為表征 size class 而生,用來區分設備。你可以在它身上獲取到足以區分所有設備的特征。 UITraitEnvironment 協議、UIContentContainer 協議 UIViewController 遵循了這兩個協議,用來監聽和設置 traitCollection 的變化。 protocol UI…

直方圖繪制與直方圖均衡化實現

一,直方圖的繪制 1.直方圖的概念: 在圖像處理中,經常用到直方圖,如顏色直方圖、灰度直方圖等。 圖像的灰度直方圖就描述了圖像中灰度分布情況,能夠很直觀的展示出圖像中各個灰度級所 占的多少。 圖像的灰度直方圖是灰…

eclipse警告與報錯的修復

1.關閉所有eclipse校驗 windows->perference->validation disable all 2.Access restriction: The constructor BASE64Decoder() is not API (restriction on required library C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar) 在builde path 移除jre,再…

時間序列因果關系_分析具有因果關系的時間序列干預:貨幣波動

時間序列因果關系When examining a time series, it is quite common to have an intervention influence that series at a particular point.在檢查時間序列時,在特定時間點對該序列產生干預影響是很常見的。 Some examples of this could be:例如: …

微生物 研究_微生物監測如何工作,為何如此重要

微生物 研究Background背景 While a New York Subway station is bustling with swarms of businessmen, students, artists, and millions of other city-goers every day, its floors, railings, stairways, toilets, walls, kiosks, and benches are teeming with non-huma…

Linux shell 腳本SDK 打包實踐, 收集assets和apk, 上傳FTP

2019獨角獸企業重金招聘Python工程師標準>>> git config user.name "jenkins" git config user.email "jenkinsgerrit.XXX.net" cp $JENKINS_HOME/maven.properties $WORKSPACE cp $JENKINS_HOME/maven.properties $WORKSPACE/app cp $JENKINS_…

opencv:卷積涉及的基礎概念,Sobel邊緣檢測代碼實現及卷積填充模式

具體參考我的另一篇文章: opencv:卷積涉及的基礎概念,Sobel邊緣檢測代碼實現及Same(相同)填充與Vaild(有效)填充 這里是對這一篇文章的補充! 卷積—三種填充模式 橙色部分為image, 藍色部分為…

怎么查這個文件在linux下的哪個目錄

因為要裝pl/sql所以要查找tnsnames.ora文件。。看看怎么查這個文件在linux下的哪個目錄 find / -name tnsnames.ora 查到: /opt/app/oracle/product/10.2/network/admin/tnsnames.ora/opt/app/oracle/product/10.2/network/admin/samples/tnsnames.ora 還可以用loca…

無法從套接字中獲取更多數據_數據科學中應引起更多關注的一個組成部分

無法從套接字中獲取更多數據介紹 (Introduction) Data science, machine learning, artificial intelligence, those terms are all over the news. They get everyone excited with the promises of automation, new savings or higher earnings, new features, markets or te…

web數據交互_通過體育運動使用定制的交互式Web應用程序數據科學探索任何數據...

web數據交互Most good data projects start with the analyst doing something to get a feel for the data that they are dealing with.大多數好的數據項目都是從分析師開始做一些事情,以便對他們正在處理的數據有所了解。 They might hack together a Jupyter n…

C# .net 對圖片操作

using System.Drawing;using System.Drawing.Drawing2D;using System.Drawing.Imaging;public class ImageHelper{/// <summary>/// 獲取圖片中的各幀/// </summary>/// <param name"pPath">圖片路徑</param>/// <param name"pSaveP…

數據類型之Integer與int

數據類型之Integer與int Java入門 基本數據類型 眾所周知&#xff0c;Java是面向對象的語言&#xff0c;一切皆對象。但是為了兼容人類根深蒂固的數據處理習慣&#xff0c;加快常規數據的處理速度&#xff0c;提供了9種基本數據類型&#xff0c;他們都不具備對象的特性&#xf…

PCA(主成分分析)思想及實現

PCA的概念&#xff1a; PCA是用來實現特征提取的。 特征提取的主要目的是為了排除信息量小的特征&#xff0c;減少計算量等。 簡單來說&#xff1a; 當數據含有多個特征的時候&#xff0c;選取主要的特征&#xff0c;排除次要特征或者不重要的特征。 比如說&#xff1a;我們要…

【安富萊二代示波器教程】第8章 示波器設計—測量功能

第8章 示波器設計—測量功能 二代示波器測量功能實現比較簡單&#xff0c;使用2D函數繪制即可。不過也專門開辟一個章節&#xff0c;為大家做一個簡單的說明&#xff0c;方便理解。 8.1 水平測量功能 8.2 垂直測量功能 8.3 總結 8.1 水平測量功能 水平測量方…

深度學習數據更換背景_開始學習數據科學的最佳方法是了解其背景

深度學習數據更換背景數據科學教育 (DATA SCIENCE EDUCATION) 目錄 (Table of Contents) The Importance of Context Knowledge 情境知識的重要性 (Optional) Research Supporting Context-Based Learning (可選)研究支持基于上下文的學習 The Context of Data Science 數據科學…