九度 oj 题目1087:约数的个数

来源:互联网 发布:朱敏希28分钟 知乎 编辑:程序博客网 时间:2024/05/16 11:07

http://ac.jobdu.com/problem.php?pid=1087


照抄了 http://blog.csdn.net/jdplus/article/details/18353667


#include <stdio.h>#include <cmath>int main(){     //freopen("in/1087.in","r",stdin);     int n;    int a[1001];     while(scanf("%d",&n)!=EOF && n ){         for (int i = 0; i < n; ++i) {             scanf("%d", &a[i]);          }           for (int i = 0; i < n; ++i) {             int cnt = 0;            int root =(int) sqrt(a[i]*1.0);              for (int j = 1; j <=root; j++) {                if(a[i]%j == 0){                    cnt +=2;                }                }             if(root * root == a[i]) cnt--;             printf("%d\n",cnt);         }     }  }  


0 0