反演一下可以得到$b_i=\sum\limits_{d=1}^i{\mu(i)(\lfloor \frac{i}{d} \rfloor})^n$

整除分块的话会T, 可以维护一个差分, 优化到$O(nlogn+klogk)$

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <string.h>
#include <bitset>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(i,1,n) cout<<a[i]<<' ';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
//head const int N = 2e6+10;
int n, k, mu[N];
ll po[N], sum[N]; int main() {
scanf("%d%d", &n, &k);
mu[1] = 1;
REP(i,1,N-1) {
for (int j=2*i; j<=N-1; j+=i) mu[j]-=mu[i];
po[i] = qpow(i,n);
}
ll ans = 0;
REP(i,1,k) {
if (mu[i]) for (int j=i; j<=k; j+=i) {
sum[j]+=mu[i]*(po[j/i]-po[j/i-1]);
}
(sum[i]+=sum[i-1])%=P;
if (sum[i]<0) sum[i]+=P;
ans+=i^sum[i];
}
printf("%lld\n", (ans%P+P)%P);
}

Coprime Arrays CodeForces - 915G (数论水题)的更多相关文章

  1. A. Arrays(Codeforces Round #317 水题)

    A. Arrays time limit per test 2 seconds memory limit per test 256 megabytes input standard input out ...

  2. Codeforces数据结构(水题)小结

    最近在使用codeblock,所以就先刷一些水题上上手 使用codeblock遇到的问题 1.无法进行编译-------从setting中的编译器设置中配置编译器 2.建立cpp后无法调试------ ...

  3. CodeForces 705A Hulk (水题)

    题意:输入一个 n,让你输出一行字符串. 析:很水题,只要判定奇偶性,输出就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,10240 ...

  4. Vasya and Beautiful Arrays CodeForces - 354C (数论,枚举)

    Vasya and Beautiful Arrays CodeForces - 354C Vasya's got a birthday coming up and his mom decided to ...

  5. HDU 3215 The first place of 2^n (数论-水题)

    The first place of 2^n Problem Description LMY and YY are mathematics and number theory lovers. They ...

  6. CodeForces 705B (训练水题)

    题目链接:http://codeforces.com/problemset/problem/705/B 题意略解: 两个人玩游戏,解数字,一个数字可以被分成两个不同或相同的数字 (3可以解成 1 2) ...

  7. codeforces hungry sequence 水题

    题目链接:http://codeforces.com/problemset/problem/327/B 这道题目虽然超级简单,但是当初我还真的没有想出来做法,囧,看完别人的代码恍然大悟. #inclu ...

  8. codeforces 377A. Puzzles 水题

    A. Puzzles Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/33 ...

  9. CodeForces 474B Worms (水题,二分)

    题意:给定 n 堆数,然后有 m 个话询问,问你在哪一堆里. 析:这个题是一个二分题,但是有一个函数,可以代替写二分,lower_bound. 代码如下: #include<bits/stdc+ ...

随机推荐

  1. npm的安装和使用?

    参考: http://www.cnblogs.com/chyingp/p/npm.html 在css中使用变量, 采用less或sass来编译css 改变网页网站开发和构建的方式, 除了用emmet( ...

  2. P2042 [NOI2005]维护数列

    思路 超级恶心的pushdown 昏天黑地的调 让我想起了我那前几个月的线段树2 错误 这恶心的一道题终于过了 太多错误,简直说不过来 pushup pushdown 主要就是这俩不太清晰,乱push ...

  3. Jenkins serving Cake: our recipe for Windows

    https://novemberfive.co/blog/windows-jenkins-cake-tutorial/ Where we started, or: why Cake took the ...

  4. 比赛总结——牛客网 NOIP赛前集训营提高组模拟第一场

    第一场打的很惨淡啊 t1二分+前缀最小值没想出来,20分的暴力也挂了,只有10分 t2数位dp,调了半天,结果因为忘了判0的特殊情况WA了一个点,亏死 t3emmmm.. 不会 imone说是DSU ...

  5. 一文读懂 深度强化学习算法 A3C (Actor-Critic Algorithm)

    一文读懂 深度强化学习算法 A3C (Actor-Critic Algorithm) 2017-12-25  16:29:19   对于 A3C 算法感觉自己总是一知半解,现将其梳理一下,记录在此,也 ...

  6. Bytomd 助记词恢复密钥体验指南

    比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchain/bytom 背景知识 ...

  7. 【C#】非常重要的泛型

    泛型 为什么要有泛型, 在没有泛型之前, 什么东西充当了泛型的作用? 在泛型出现之前, 代码中会有很多需要强制转换的地方. 比如 int a = (int) object, 对于这样类似的代码, 编译 ...

  8. Kylin web界面 知识点介绍

    Big Data Era: 1.More and more data becoming available on Hadoop2.Limitations in existing Business ...

  9. UVa 11624 Fire!(着火了!)

    UVa 11624 - Fire!(着火了!) Time limit: 1.000 seconds Description - 题目描述 Joe works in a maze. Unfortunat ...

  10. 原生JS取代一些JQuery方法的简单实现

    原生JS取代一些JQuery方法的简单实现 下面小编就为大家带来一篇原生JS取代一些JQuery方法的简单实现.小编觉得挺不错的,现在就分享给大家,也给大家做个参考.一起跟随小编过来看看吧   1.选 ...