• HDU 2608 底数优化分块 暴力


    T(n) as the sum of all numbers which are positive integers can divied n. and S(n) = T(1) + T(2) + T(3)…..+T(n). 

    定义T(n)为n的因子和($sigma(n)$),求$S(n) % 2=sumlimits_{i=1}^{n}T(i) mod 2$,n<=1e9。

    你总是说找规律,可是找规律已经累了。找规律不想对付数论题,它想做水题(这个就是呀),你考虑过它的感受吗?没有!你只关心你自己。找规律天下第一!(吃面)

    $ans=sumlimits_{i=1}^{n}sumlimits_{d|i}d=sumlimits_{d}^{n}lfloorfrac{n}{d} floor d$

    底数优化,重复项是等差数列的和(不用我说吧)..复杂度$O(sqrt{n})$

    /** @Date    : 2017-09-20 23:16:50
      * @FileName: HDU 2608 分块 容斥.cpp
      * @Platform: Windows
      * @Author  : Lweleth (SoungEarlf@gmail.com)
      * @Link    : https://github.com/
      * @Version : $Id$
      */
    #include <bits/stdc++.h>
    #define LL long long
    #define PII pair<int ,int>
    #define MP(x, y) make_pair((x),(y))
    #define fi first
    #define se second
    #define PB(x) push_back((x))
    #define MMG(x) memset((x), -1,sizeof(x))
    #define MMF(x) memset((x),0,sizeof(x))
    #define MMI(x) memset((x), INF, sizeof(x))
    using namespace std;
    
    const int INF = 0x3f3f3f3f;
    const int N = 1e5+20;
    const double eps = 1e-8;
    
    
    int main()
    {
    	int T;
    	cin >> T;
    	while(T--)
    	{
    		LL n;
    		scanf("%lld", &n);
    		LL ans = 0;
    		for(LL i = 1, j; i <= n; i = j + 1)
    		{
    			cout << i << endl;
    			j = (n /(n / i));
    			ans += (n / i) * (i + j) * (j - i + 1) / 2;
    			cout << ans << endl;
    		}
    		printf("%lld
    ", ans);
    	}
        return 0;
    }
    
  • 相关阅读:
    iOS 定制controller过渡动画 ViewController Custom Transition使用体会
    iOS 和 Android 中的Alert
    iOS 中的frame,bounds,center,transform关联
    Android Services重点记录
    iOS 中的字体预览
    iOS 中关于ViewController总结
    iOS7 和 iOS6的页面兼容问题
    docker安装并修改Nginx镜像
    docker环境搭建
    Eclipse中.setting目录下文件介绍
  • 原文地址:https://www.cnblogs.com/Yumesenya/p/7566161.html
Copyright © 2020-2023  润新知