Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不需要枚举,直接分解质因子就可以了

Posted by lyyshp at 2019-06-01 11:59:18 on Problem 2140
#include <stdio.h>
#include <math.h>
#define M 13

int main()
{	 
	int x, i, j, k, p[M], n, T;
	int d, ans;
	 	
	scanf("%d", &n);
	k = sqrt(x = n << 1), i = 2;
	int q[M] = {0}, c = 0;    
	while(i <= k){
	    if(x % i == 0){
	        p[c] = i;
	        j = 1;
	        do{
	            x /= i;
	            j++;
	        }while(x % i == 0);
	        k = sqrt(x);
	        q[c++] = j;
	    }
	    i++;
	}
	if(x > 1){
	    p[c] = x, q[c] = 2;
	    c++;
	}
	for(i = ans = 1; i < c; i++) ans *= q[i];
	printf("%d\n", ans);
	
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator