zoukankan      html  css  js  c++  java
  • [信息OJ 2467] Asakura的难题

     2467: G Asakura的难题

    Time Limit:2000MS Memory Limit:65536KB
    Asakura是班里有名的捣蛋鬼,所以经常有同学到老师那里去告状。今天老师想出个题恶心一下Asakura,题目如下:
    F(n)=∑| n/i | , (i=1,2,3…..n)
    |x|为x向下取整,比如|3.5|=3。
    
    Asakura想了想,很快就求出了F(n)。
    
    多组输入
    对于每组测试数据:
    第一行输入一个整数n(1<=n<=10^10) 
    
    每组输出只包含一个整数,代表F(n)的值。
    Sample Input
    1
    2
    3
    

      Sample Output

    1
    3
    5
    
    额、- -
    注意用long long
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    using namespace std;
    #define ll long long
    
    ll solve(ll n)
    {
        ll ans=0;
        ll i,x,y,t;
        for(i=1;i<=n;i++){
            x=n/i;
            y=n%i;
            t=y/x;
            ans+=(t+1)*x;
            i+=t;
        }
        return ans;
    }
    int main()
    {
        ll n;
        while(scanf("%lld",&n)!=EOF){
            printf("%lld
    ",solve(n));
        }
        return 0;
    }
    趁着还有梦想、将AC进行到底~~~by 452181625
  • 相关阅读:
    品优购注册页
    品优购详情页---产品细节模块product_detail
    品优购详情页---产品详细信息区域 iteminfo_wrap
    poj 3684
    POJ 2785
    POJ 3185
    POJ 3279
    POJ 3276
    POJ 2566
    POJ 2100
  • 原文地址:https://www.cnblogs.com/hate13/p/4491336.html
Copyright © 2011-2022 走看看