zoukankan      html  css  js  c++  java
  • 算法提高 约数个数

    http://lx.lanqiao.org/problem.page?gpid=T209

    算法提高 约数个数  
    时间限制:1.0s   内存限制:512.0MB
        
      输入一个正整数N (1<= N <= 10 ^ 6),输出N的约数的个数。
    样例输入
    12
    样例输出
    6
    样例说明
      12的约数包括:1,2,3,4,6,12。共6个
     
    分析:
     
    直接模拟输出约数即可。
     
    AC代码:
     
     1 #include <stdio.h>
     2 #include <algorithm>
     3 #include <iostream>
     4 #include <string.h>
     5 #include <string>
     6 #include <math.h>
     7 #include <stdlib.h>
     8 #include <queue>
     9 #include <stack>
    10 #include <set>
    11 #include <map>
    12 #include <list>
    13 #include <iomanip>
    14 #include <vector>
    15 #pragma comment(linker, "/STACK:1024000000,1024000000")
    16 #pragma warning(disable:4786)
    17 
    18 using namespace std;
    19 
    20 const int INF = 0x3f3f3f3f;
    21 const int Max = 10000 + 10;
    22 const double eps = 1e-8;
    23 const double PI = acos(-1.0);
    24 
    25 int main()
    26 {
    27     int n , ans = 0;
    28     scanf("%d", &n);
    29     for(int i = 1;i <= n;i ++)
    30     {
    31         if(n % i == 0)
    32             ans ++;
    33     }
    34     printf("%d
    ",ans);
    35     return 0;
    36 }
    View Code
  • 相关阅读:
    nlogn LIS CF1437E
    CF 1444B
    unsigned int慎用
    CF1425D 容斥 组合数 快速幂求逆元
    CF 1408D探照灯 找 匪
    各种状态转移
    CF 459C
    主席树 入门
    杭州特色景致的性价比精致餐厅
    SQL函数总结
  • 原文地址:https://www.cnblogs.com/jeff-wgc/p/4450778.html
Copyright © 2011-2022 走看看