zoukankan      html  css  js  c++  java
  • LightOJ1245 Harmonic Number (II)

     1 /*
     2  LightOJ1245 Harmonic Number (II)
     3  http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1245
     4  数论 求和
     5  */
     6 #include <cstdio>
     7 #include <algorithm>
     8 #include <cstring>
     9 #include <cmath>
    10 #include <vector>
    11 #include <queue>
    12 #include <iostream>
    13 #include <map>
    14 #include <set>
    15 //#define test
    16 using namespace std;
    17 const int Nmax=1e6+7;
    18 int main()
    19 {
    20     #ifdef test
    21     #endif
    22     int t;
    23     scanf("%d",&t);
    24     t=0;
    25     long long n;
    26     while(scanf("%lld",&n)==1)
    27     {
    28         t++;
    29         long long ans=0LL;
    30         long long r=sqrt(n);
    31         long long i;
    32         for(i=1LL;i<=r;i++)
    33             ans+=n/i;
    34         ans*=2LL;
    35         ans-=(i-1LL)*(i-1LL);
    36         printf("Case %d: %lld
    ",t,ans);
    37     }
    38     //for(int n=1;n<=25;n++)
    39     //for(int i=1;i<=n;i++)
    40     //{
    41         //printf("%3d%c",n/i,i==n?'
    ':' ');
    42     //}
    43 
    44     return 0;
    45 }
  • 相关阅读:
    KafKa 发消息到Storm
    HBase的优化
    HBase部署与使用
    Scala 类
    Scala高阶函数
    模式匹配
    Scala数据结构
    scala基础语法
    Scala安装配置
    Kafka工作流程分析
  • 原文地址:https://www.cnblogs.com/BBBob/p/6708707.html
Copyright © 2011-2022 走看看