题意:

  求解合为 y 的总体 gcd 为 x 的正整数非空序列个数。

解法:

  特判一下后,原问题等价于合为 s = y/x 的整体gcd为1的正整数序列个数。

  1.$ans = \sum_{\sum{x_i} = s}{ [(x_1,...,x_n) = 1] } = \sum_{d|s}{\mu(s/d) \sum{[x_1+x_2+...+x_n = d]}} = \sum_{d|s}{\mu(s/d) 2^{d-1}}$

  2.记$f(m) = \sum_{\sum{x_i} = m}{ [(x_1,...,x_n) = 1] }$,则$\sum_{d|m}{f(m)} = 2^{m-1}$,考虑记忆化 + 递归。

  两者时间复杂度皆为$O(n^{2/3})$

Unusual Sequences的更多相关文章

  1. Codeforces 900D Unusual Sequences 容斥原理

    题目链接:900D  Unusual Sequences 题意: 给出两个数N,M.让你求数列(和为M,gcd为N)的个数. 题解: 首先,比较容易发现的是M%N如果不为零,那么一定不能构成这样的序列 ...

  2. 【CF900D】Unusual Sequences 容斥(莫比乌斯反演)

    [CF900D]Unusual Sequences 题意:定义正整数序列$a_1,a_2...a_n$是合法的,当且仅当$gcd(a_1,a_2...a_n)=x$且$a_1+a_2+...+a_n= ...

  3. CodeForces - 900D: Unusual Sequences (容斥&莫比乌斯&组合数学)

    Count the number of distinct sequences a1, a2, ..., an (1 ≤ ai) consisting of positive integers such ...

  4. CodeForces 900D Unusual Sequences

    题目链接: https://codeforces.com/contest/900/problem/D 题意 假设有distinct 正整数序列{a1,a2,,,an},满足gcd(a1, a2, .. ...

  5. cf900D. Unusual Sequences(容斥 莫比乌斯反演)

    题意 题目链接 Sol 首先若y % x不为0则答案为0 否则,问题可以转化为,有多少个数列满足和为y/x,且整个序列的gcd=1 考虑容斥,设\(g[i]\)表示满足和为\(i\)的序列的方案数,显 ...

  6. Codeforces 900D Unusual Sequences:记忆化搜索

    题目链接:http://codeforces.com/problemset/problem/900/D 题意: 给定x,y,问你有多少个数列a满足gcd(a[i]) = x 且 ∑(a[i]) = y ...

  7. Codeforces Round #450 (Div. 2) D.Unusual Sequences (数学)

    题目链接: http://codeforces.com/contest/900/problem/D 题意: 给你 \(x\) 和 \(y\),让你求同时满足这两个条件的序列的个数: \(a_1, a_ ...

  8. CF 900D Unusual Sequences

    题目链接 \(Description\) 给定\(x,y\),求有多少个数列满足\(gcd(a_i)=x且\sum a_i=y\).答案对\(10^9+7\)取模. \(1≤x,y≤10^9\) \( ...

  9. 【CF900D】Unusual Sequences

    题目 智力下降严重 显然要反演了呀 首先必须满足\(x|y\),否则答案是\(0\) 我们枚举这个数列的\(gcd\)是\(d\)或者\(d\)的倍数 于是答案就是 \[\sum_{x|d}[d|y] ...

随机推荐

  1. UVALive - 7045 Last Defence 【数学】

    题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  2. PAT天梯赛 L2-019. 悄悄关注 【STL】

    题目链接 https://www.patest.cn/contests/gplt/L2-019 思路 将已关注的人 用 MAP存起来 然后将点赞的用户中 没有关注的 用 VECTOR 存下来 并且求出 ...

  3. 每天一个Linux命令(20)find命令_exec参数

    find命令的exec参数,用于find查找命令完成以后的后续操作.     (1)用法: 用法:  [find命令]  [-exec  其他命令 {} \;]     (2)功能: 功能:-exec ...

  4. 【leetcode刷题笔记】Jump Game

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  5. CSS3环形动画菜单

    在线演示 本地下载

  6. 第二十四篇、socketserver源码剖析

    这里选择的是python2.7(python3和2.7的源码基本类似) #!/usr/bin/env python # -*- coding:utf-8 -*- import SocketServer ...

  7. mini2440移植uboot 2014.04(四)

    我修改的代码已经上传到github上,地址:https://github.com/qiaoyuguo/u-boot-2014.04-mini2440.git 参考文章: <mini2440移植u ...

  8. django配置文件环境分离后celery的启动方式整理

    django项目中,当配置文件分离时: 启动方式1: 硬编码写死在manage.py中: os.environ.setdefault("DJANGO_SETTINGS_MODULE" ...

  9. DELPHI线程例子-FC

    {优秀的数据库应用应当充分考虑数据库访问的速度问题.通常可以通过优化数据库.优化 查询语句.分页查询等途径收到明显的效果.即使是这样,也不可避免地会在查询时闪现一个带有 SQL符号的沙漏,即鼠标变成了 ...

  10. django中使用多个数据库,跨库查询

    一.settings配置多个数据库 DATABASES = { 'default': { # 'ENGINE': 'django.db.backends.mysql', 'ENGINE': 'comm ...