https://codeforces.com/contest/1139/problem/D

题解:莫比乌斯+无穷级数

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=200000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q;
int ans,cnt,flag,temp,sum;
int a[N];
char str;
struct node{};
ll powl(ll a, ll n, ll p)    //快速幂 a^n % p
{ll ans = 1;while(n){if(n & 1) ans = ans * a % p;a = a * a % p;n >>= 1;}return ans;
}
ll niYuan(ll a, ll b)   //费马小定理求逆元
{return powl(a, b - 2, b);
}ll cal(ll a, ll b)    //计算C(a, b)
{return a*niYuan(b,MOD) % MOD;
}
int Miu[N] , Prime[N] , Pris ;
bool P[N] ;
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);Miu[1] = 1 ;for(register int i = 1 ; ++i <= n ; ) {if( not P[i] ) {Prime[++Pris] = i ;Miu[i] = 1 ;}for(register int j = 0 ; ++j <= Pris ; ) {register int S = i * Prime[j] ;if( S > n ) break ;P[S] = 1 ;if( i % Prime[j] ) Miu[S] = -Miu[i] ;else {Miu[S] = 0 ;break ;}}}int Ansa = 1 , Ansb = 1 ;for(register int i = 1 ; ++i <= n ; ) {if( Miu[i] == 0 ) continue ;register int Thea = n / i , Theb = n - Thea ;if( Miu[i] == -1 ) Thea = MOD - Thea ;Ansa = ( 1ll * Ansa * Theb + 1ll * Ansb * Thea ) % MOD;Ansb = 1ll * Ansb * Theb % MOD ;}return not printf( "%lld\n" , cal(Ansa,Ansb) ) ;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Steps to One相关推荐

  1. SAP QM Basic Steps to Create Dynamic Modification Rule

    Basic Steps to Create Dynamic Modification Rule Process: Quality Management –> Inspection Plannin ...

  2. [练习]利用CSS steps 实现逐帧动画

    网页逐帧动画的实现方式 网页中的逐帧动画,大致可分为两大类的实现方式, 分别是使用JS控制,和单纯使用CSS实现,两者的优劣总体概括来说就是: JS动画可控性更强,但开销大,实现复杂. CSS动画实现 ...

  3. 用animation的steps属性制作帧动画

    昨天火急火燎地接到一个任务,说是要做一个掷骰子的游戏,关于掷骰子期间的过渡动画,我本来是想用css 3d制作一个立体的骰子,然后叫UI给6张平面图贴上去.再用translate3d来操作.然而UI考虑 ...

  4. you should specify the `steps` argument

    you should specify the steps argument self.model.predict(img_tensor,steps = 1)

  5. CSS3 animation-timing-function steps()

    animation-timging-function 主要是控制css动画从开始到结束的速度. linear:线性过渡.等同于贝塞尔曲线(0.0, 0.0, 1.0, 1.0)ease:平滑过渡.等同 ...

  6. 7 Steps for becoming Deep Learning Expert

    转载自: 7 Steps for becoming Deep Learning Expert | Ankit Agarwal | 领英 https://www.linkedin.com/pulse/7 ...

  7. 6kyu Steps in k-prime

    6kyu Steps in k-primes 题目背景: A natural number is called k-prime if it has exactly k prime factors, c ...

  8. 给element-ui的steps加点击事件

    添加@click 添加之后发现不好使 找了一番资料发现得这样写就可以了@click.native 这个native是什么作用呢? 查了一番资料大概就是vue封装@click这些方法时阻止了原生的DOM ...

  9. Top 10 steps to optimize data access in SQL Server

    2009年04月28日 Top 10 steps to optimize data access in SQL Server: Part I (use indexing) 2009年06月01日 To ...

  10. Steps to configure Oracle 11g Data Guard Physical Standby – Active Data Guard Part-I

    2019独角兽企业重金招聘Python工程师标准>>> Steps to configure Oracle 11g Data Guard Physical Standby – Act ...

最新文章

  1. 增加自增列 耗时长_又一批长事务,P0故障谁来背锅?
  2. Data Guard搭建困境突围(一)
  3. linux卸载minicom,ubuntu下minicom超级终端的使用方法
  4. matlab中find函数_在R中使用Matlab函数
  5. 完课率最高 | 带学吴恩达《机器学习》课程和作业,带打Kaggle全球顶级大赛!...
  6. python使用urllib模块开发的多线程豆瓣小站mp3下载器
  7. python学习之自习语法(20180626_update)
  8. Swift之深入解析可选链的功能和使用
  9. 攻击防护手段_如何防护ddos流量攻击?
  10. 2018-09-29 摘抄eDP取代LVDS视频接口
  11. 平板电脑办公软件_办公软件便签电脑版免费下载
  12. pandas中replace的用法
  13. 利用子查询解决复杂sql问题
  14. C++ 二叉树求叶子结点数及输出叶子结点的路径
  15. 2020山东大学软件测试期末试题
  16. 如何用牛顿迭代法求平方根
  17. 圆通快递查询电子面单接口对接快递鸟api指南
  18. vue部署到内网和外网配置简要说明
  19. mint-ui —— checklist的使用
  20. VS2005编译器选项

热门文章

  1. 服务器打不QQ显示00001,QQ登录超时00001怎么处理?
  2. 数学教师计算机能力提升,数学教师信息技术应用能力提升培训总结.doc
  3. 指针冒泡排序c语言代码,用指针编写冒泡排序方法
  4. 当double类型数学计算精度偏差解决
  5. rabbitmq 启动异常_RabbitMQ:消息发送确认 与 消息接收确认(ACK)
  6. python读取raw数据文件_Python 读写文件中数据
  7. SVM支持向量机(下)
  8. ICLR 2022 | Transformer不比CNN强!Local Attention和动态Depth-wise卷积
  9. 用文本指导文本:基于文本的自监督可控文本生成模型
  10. 泛化性乱弹:从随机噪声、梯度惩罚到虚拟对抗训练