約數的個數

Description

?

mmoaay小侄子今年上初中,老師出了一道求約數個數的題目,比如8的約數有1,2,4,8共4個。

當數比較小的時候可以人工算,當n較大時就難了。

mmoaay嫌麻煩,現在讓你編個程序來算。

Input

一行一個整數。最后以0結束。

Output

分別求出這些整數的約數個數,最后的0不用處理。

Sample Input

8
100
0

Sample Output

4
9

一個知識點:任何數都可以寫成2的p1次方乘以3的p2次方乘以5的p3次方……也就是素數的乘積 ?約數的個數是(p1+1)*(p2+1)……

AC代碼

#include <iostream>
#include<stdio.h>
using namespace std;
#include <string.h>
int main()
{int n,i;while(1){scanf("%d",&n);if(n==0)break;int d=1;for(i=2;n!=1;i++){int c=1;while(n%i==0){c++;n/=i;}d*=c;}printf("%d\n",d);}return 0;
}

The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of years is the question of primality. A prime number is a number that is has no proper factors (it is only evenly divisible by 1 and itself). The first prime numbers are 2,3,5,7 but they quickly become less frequent. One of the interesting questions is how dense they are in various ranges. Adjacent primes are two numbers that are both primes, but there are no other prime numbers between the adjacent primes. For example, 2,3 are the only adjacent primes that are also adjacent numbers.?
Your program is given 2 numbers: L and U (1<=L< U<=2,147,483,647), and you are to find the two adjacent primes C1 and C2 (L<=C1< C2<=U) that are closest (i.e. C2-C1 is the minimum). If there are other pairs that are the same distance apart, use the first pair. You are also to find the two adjacent primes D1 and D2 (L<=D1< D2<=U) where D1 and D2 are as distant from each other as possible (again choosing the first pair if there is a tie).

Input

Each line of input will contain two positive integers, L and U, with L < U. The difference between L and U will not exceed 1,000,000.

Output

For each L and U, the output will either be the statement that there are no adjacent primes (because there are less than two primes between the two given numbers) or a line giving the two pairs of adjacent primes.

Sample Input

2 17
14 17

Sample Output

2,3 are closest, 7,11 are most distant.
There are no adjacent primes.

題意:判斷相鄰的素數差最小與差最大

轉載于:https://www.cnblogs.com/zcy19990813/p/9702706.html

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

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

相關文章

SQL Server Management Studio清除歷史登陸記錄

今天做滲透,登陸目標服務器的數據庫管理后發現留下了登陸的記錄,自己鼓搗了半天,終于解決 刪除C:\Documents and Settings\guest\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell下的 mru.dat文件就可以了 本文轉sinojelly51CTO博客&#xff0c;原文鏈接&…

停止抱怨英語_停止抱怨垂直視頻

停止抱怨英語People have strong feelings about which direction video should be oriented. There are good reasons for that, but in some contexts, vertical video is completely fine and you should stop complaining about it. 人們對視頻應該定向哪個方向有著強烈的感…

Google Play/App Store/Facebook多賬號關聯問題,你會判斷嗎?

對于海外游戲開發、海外發行公司&#xff0c;尤其是有多個APP產品的公司來說&#xff0c;多賬號關聯問題是他們必然會遇到的。與亞馬遜等電商平臺直接禁止申請多家店鋪的做法不同&#xff0c;Google Play/App Store/Facebook等平臺申請多賬號的風險相對后置&#xff0c;平臺會從…

MySQL數據庫服務器優化詳細

查看MySql狀態及變量的方法&#xff1a; Mysql> show status ——顯示狀態信息&#xff08;擴展show status like XXX&#xff09; Mysql> show variables ——顯示系統變量&#xff08;擴展show variables like XXX&#xff09; Mysql> show innodb status ——顯示I…

facebook_如何清除您的Facebook搜索記錄

facebookSearch histories can tell a lot about you, and that’s especially true of Facebook’s search history. If you don’t want that sort of data left sitting around, here’s how to clear it. 搜索歷史可以告訴您很多信息&#xff0c;Facebook的搜索歷史尤其如此…

UI交互設計教程分享:提高界面交互體驗的“葵花寶典”

?本次分享的是在界面設計中最長實用也最容易被忽略的十個原則&#xff0c;就是尼爾森十大可用性設計原則&#xff0c;這是十分基礎且重要的原則。原則是死的&#xff0c;如何正確的結合到實際運用中才是關鍵。接下來我會通過對每一個原則的理解和現在移動端產品和結合進行分析…

window專業版激活

1、管理員權限進入命令行 2、安裝密鑰 slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX 3、設置kms服務器 slmgr /skms zh.us.to 4、查看是否激活 slmgr /ato 轉載于:https://www.cnblogs.com/Edward-Yue/p/10942884.html

csv文件用什么打開_什么是CSV文件,如何打開它?

csv文件用什么打開A Comma Separated Values (CSV) file is a plain text file that contains a list of data. These files are often used for exchanging data between different applications. For example, databases and contact managers often support CSV files. 逗號…

Python連續攀升,其他的腳本語言去哪了?

Python在TIOBE排行榜排名連續攀升&#xff0c;它的優勢掩蓋了一個嚴肅的問題&#xff1a;其他的腳本語言去哪兒了?據2017年11月的TIOBE指數顯示&#xff0c;其他語言(如Perl&#xff0c;PHP和Ruby)排名正在緩慢下滑。 不久之前&#xff0c;腳本語言風靡一時。動態類型語言不僅…

div水平垂直居中

水平垂直居中 效果 html <div class"m-box"><div class"m-temp"><div class"m-item">fsdafsfasdf</div><div class"m-item">fsdafsfasdf</div><div class"m-item">fsdafsfasdf&l…

【C】C語言結構體指針的語法

#include <stdio.h> #include <string.h> #include <stdlib.h>struct AGE {int year;int month;int day; };struct Student {char *name;int num;struct AGE birthday;float score; };int main() {// 注意寫法1與寫法2 不能混用// 寫法1struct Student* stu …

禁用磁盤檢查_如何在Windows上禁用“磁盤空間不足”警告

禁用磁盤檢查Windows displays “Low Disk Space” notifications whenever any partition on your computer has less than 200 MB of space remaining. Here’s how to get rid of the notifications, even if you can’t free up the space. 只要計算機上任何分區的剩余空間…

java根據身份證號碼計算年齡的方法(精確到日)

/*** 根據身份證號碼計算年齡** param psptNo* return*/public int getAgeByPsptNo(String psptNo) {if (StringUtils.isEmpty(psptNo)) {return 0;}String birthDay psptNo.substring(6, 14);String time new SimpleDateFormat("yyyy-MM-dd").format(new Date());…

ZT:CSS實現水平|垂直居中漫談

有篇博客園網友‘云軒奕鶴’的文章不錯&#xff0c;轉載在這里以供需要時查閱。 http://www.cnblogs.com/jadeboy/p/5107471.html 本文轉自張昺華-sky博客園博客&#xff0c;原文鏈接&#xff1a;http://www.cnblogs.com/xiandedanteng/p/6271281.html&#xff0c;如需轉載請自…

facebook數據_Facebook的“下載數據”功能遺漏了很多

facebook數據Facebook lets you download a ZIP file with all of your data—in theory. Turns out a lot of information isn’t included. 從理論上講&#xff0c;Facebook可讓您下載包含所有數據的ZIP文件。 事實證明&#xff0c;其中不包含很多信息。 Here’s Nitasha Tik…

直播源碼中有哪些網絡協議需要注意?

在當今的直播平臺中&#xff0c;對直播源碼越來越注重。那么直播源碼中有哪些網絡協議需要注意的呢&#xff1f; 1.TCP&#xff1a;TCP為點對點的協議&#xff0c;雖然能保證了數據傳輸的可靠性&#xff0c;但是對服務器資源耗費較大&#xff0c;在數據流大的場合難以保證數據流…

tomcat一閃而過

JAVA_HOME should point to a JDK not a JRE |vista tomcat 有的朋友在啟動Tomcat的時候會出現問題。 1例如&#xff1a; 手動點擊startup.bat 后 &#xff0c;一閃而過 2例如&#xff1a;在cmd下 進到tomcat的bin目錄 運行 startup.bat &#xff0c;然后輸出 了JAVA_HOME shou…

Shell 快速指南

███████╗██╗ ██╗███████╗██╗ ██╗ ██╔════╝██║ ██║██╔════╝██║ ██║ ███████╗███████║█████╗ ██║ ██║ …

UmiJS CDN 部署之 publicPath

為什么80%的碼農都做不了架構師&#xff1f;>>> 靜態資源在非根目錄或 cdn 這時&#xff0c;就需要配置 publicPath。至于 publicPath 是啥&#xff1f;具體看 webpack 文檔&#xff0c;把他指向靜態資源&#xff08;js、css、圖片、字體等&#xff09;所在的路徑。…

check corners_免費下載:將Mac樣式的Hot Corners添加到Windows 10

check cornersWindows: Move your mouse to any corner to quickly see all your open windows, your desktop, or even start your screen saver. Windows&#xff1a;將鼠標移到任意角落可快速查看所有打開的窗口&#xff0c;桌面&#xff0c;甚至啟動屏幕保護程序。 It’s c…