AC代碼:
import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int sum = 0; for(int i=1; i*i<=n; i++) { if(n % i == 0) { if(i * i == n) sum += 1; else sum += 2; } } System.out.PRintln(sum); } } 算法提高 約數(shù)個(gè)數(shù) 時(shí)間限制:1.0s 內(nèi)存限制:512.0MB 輸入一個(gè)正整數(shù)N (1樣例輸入12樣例輸出6樣例說明 12的約數(shù)包括:1,2,3,4,6,12。共6個(gè)
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注