因式分解模板
•
tn=n;
•
for(i=2;i*i<=n;i++)
//
试除
2~sqrt(n)
•
if(tn%i==0){
//
如果能被
i
整除
•p[++cnt]=i;
//
保存底数
•e[cnt]=0;
//
保存指数
•while(tn%i==0){
//
计算指数
•
e[cnt]++;
•tn/=i;
•}
•}
•
}
•
if(tn>1){
//
存在大于
sqrt(n)
的素因子
•p[++cnt]=tn;
•e[cnt]=1;
•
}
HDU1215
package D0717;
import java.io.*;
public class HDU1215 {
public static void main(String[] args) throws IOException {
StreamTokenizer st = new StreamTokenizer(new BufferedReader(
new InputStreamReader(System.in)));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
st.nextToken();
int n = (int) st.nval;
while (n-- > 0) {
st.nextToken();
int a = (int) st.nval;
int sum = 1;
for (int i = 2; i*i <= a; i++) {
if (a % i == 0) {
sum += i;
if(a/i!=i){
sum+=a/i;
}
}
}
out.println(sum);
}
out.flush();
}
}