【题目分析】

卷积很好玩啊。

【代码】

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>

#include <map>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

#define maxn 500005
#define ll long long
#define inf 0x3f3f3f3f
#define F(i,j,k) for (int i=j;i<=k;++i)
#define D(i,j,k) for (int i=j;i>=k;--i)

void Finout()
{
    #ifndef ONLINE_JUDGE
    freopen("in.txt","r",stdin);
    freopen("wa.txt","w",stdout);
    #endif
}

int Getint()
{
    int x=0,f=1; char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    while (ch>='0'&&ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

int n,k,r,l;
ll ans=0;

int main()
{
    Finout();
    n=Getint(); k=Getint();
    ans=(ll)n*(ll)k;
//    cout<<"ans  is "<<ans<<endl;
	int now=1; r=min(n,k);
    while (r)
    {
    	now=k/r;
//    	cout<<now<<" "<<n<<" "<<k<<" "<<r<<endl;
    	l=k/(now+1)+1;
//    	cout<<"now "<<now<<endl;
//    	cout<<l<<"---"<<r<<endl;
    	ans-=((ll)r+(ll)l)*((ll)r-(ll)l+1)/2LL*(ll)now;
//    	cout<<"ans is "<<ans<<endl;
    	r=l-1;
//    	cout<<"r is "<<r<<endl;
	}
	cout<<ans<<endl;
}

  

BZOJ 1257 [CQOI2007]余数之和sum ——Dirichlet积的更多相关文章

  1. BZOJ 1257: [CQOI2007]余数之和sum

    1257: [CQOI2007]余数之和sum Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 3769  Solved: 1734[Submit][St ...

  2. bzoj 1257: [CQOI2007]余数之和sum 数学 && 枚举

    1257: [CQOI2007]余数之和sum Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 1779  Solved: 823[Submit][Sta ...

  3. BZOJ 1257: [CQOI2007]余数之和sum( 数论 )

    n >= k 部分对答案的贡献为 k * (n - k) n < k 部分贡献为 ∑ (k - ⌊k / i⌋ * i)  = ∑  , ⌊k / i⌋ 相等的数是连续的一段, 此时这段连 ...

  4. BZOJ 1257: [CQOI2007]余数之和sum【神奇的做法,思维题】

    1257: [CQOI2007]余数之和sum Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 4474  Solved: 2083[Submit][St ...

  5. [BZOJ 1257] [CQOI2007] 余数之和sum 【数学】

    题目链接:BZOJ - 1257 题目分析 首先, a % b = a - (a/b) * b,那么答案就是 sigma(k % i) = n * k - sigma(k / i) * i     ( ...

  6. BZOJ 1257 [CQOI2007]余数之和sum(分块)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1257 [题目大意] 给出正整数n和k,计算j(n,k)=k mod 1 + k mod ...

  7. 1257: [CQOI2007]余数之和sum

    1257: [CQOI2007]余数之和sum Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 2001  Solved: 928[Submit][Sta ...

  8. Bzoj 1257 [CQOI2007]余数之和 (整除分块)

    Bzoj 1257 [CQOI2007]余数之和 (整除分块) 题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1257 一道简单题. 题目 ...

  9. BZOJ 1257: [CQOI2007]余数之和

    1257: [CQOI2007]余数之和 Time Limit: 5 Sec  Memory Limit: 128 MB Description 给出正整数n和k,计算j(n, k)=k mod 1 ...

随机推荐

  1. HDU 2102 A计划 经典搜索

    A计划 Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submissio ...

  2. 转:通过ant来批量执行jmeter脚本,并生成报告(附: 生成报告时报“Content is not allowed in prolog”这个错误的解决方案)

    最近在使用jmeter写脚本来进行测试,最终写了很多份脚本,然后,就在想,这么多脚本,我不可能一个一个的手动去点啊,有没有什么办法来批量运行Jmeter脚本呢? 这个时候,自然而然地想到了万能的ant ...

  3. Dev之ChartControl控件(二)— 绘制多重坐标图形

    有时针对一个ChartControl控件可能要设置多个Y轴,进行显示: 以下举个例子:如在一个Chart中显示多个指标项如图: 首先,读取数据,并对左边的Y轴最大和最小值进行设定 IndexSerie ...

  4. 一个appium 博客

    http://www.cnblogs.com/tobecrazy/category/699177.html appium Java控制Appium server start/stop 摘要: 相信很多 ...

  5. C#实现http断点下载

    我们寄希望于万能的解决方案,但是现实的情况总是很糟糕.在软件编程的世界中,技术分散的情况尤为严重,且不说各种语言拥有的优势不能融合,单就一门语言而言,就拥有众多的技术和相关技术需要学习.网络编程就是这 ...

  6. Oracle如何还原数据库

    http://blog.sina.com.cn/s/blog_6c25b1e50101ga0b.html

  7. 关于arguments.callee.caller.arguments[0]获得event的一些问题

    先从一个简单的例子说起,一个简单的button控件如下: < input  type ='button'  name ='mybtn'  id ='mybtn'  onclick ='myFun ...

  8. 实例:SSh结合Easyui实现Datagrid的分页显示

    近日学习Easyui,发现非常好用,界面很美观.将学习的心得在此写下,这篇博客写SSh结合Easyui实现Datagrid的分页显示,其他的例如添加.修改.删除.批量删除等功能将在后面的博客一一写来. ...

  9. [Java]读取文件方法大全(转)

    [Java]读取文件方法大全   1.按字节读取文件内容2.按字符读取文件内容3.按行读取文件内容 4.随机读取文件内容 public class ReadFromFile {     /**     ...

  10. (转)Permission denied: win7下面eclipse上传本地文件到DFS && 运行M/R程序时出现的同样的错误解决方法

    原文地址: http://mntms.iteye.com/blog/2095651 hadoopeclipse远程控制权限  情景一: 当在win7下面的eclipse装好插件,首次运行M/R程序的时 ...