题目连接:https://codeforces.com/contest/1228/problem/C

题目大意:g(x,y)==y^k(其中y^k是X的最大可以整除因子)

     f(x,y)==g(x,p1)*(x,p2)....其中pi是x的第i个质因子

求f(x,1)*f(x,2)*f(x,3)---*f(x,n);

题解:对于整数N....N/x==从1到N可以被X整除的个数N/x^2同理。。。

所以我们不妨对每个质因子进行叠加,对于第一个p1,让N多次除以p1,同时记录可以整除的个数,最终我们就可以统计p1的总个数,其他质因子类似。

AC代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+;
const int N=1e5+;
int arr[N];
ll ksm(ll x,ll y){
ll res=;
while(y){
if(y&) res=(res%mod*x%mod)%mod;
y>>=;
x=(x%mod*x%mod)%mod;
}
return res%mod;
}
int main(){
ll n,m;
cin>>n>>m;
ll pos=;
for(ll i=;i*i<=n;i++){
if(n%i==){
arr[pos++]=i;
while(n%i==) n/=i;
}
}
if(n!=) arr[pos++]=n;
ll ans=;
for(ll i=;i<pos;i++){
ll z=m;
ll t2=;
while(z){
ll t1=z/arr[i];
z/=arr[i];
t2+=t1;
}
ans=(ans%mod*ksm(arr[i],t2)%mod)%mod;
}
cout<<ans<<endl;
return ;
}

C. Primes and Multiplication的更多相关文章

  1. Primes and Multiplication

    C - Primes and Multiplication 思路:找到x的所有质数因子,用一个vector储存起来,然后对于每一个质因子来说,我们要找到它对最后的答案的贡献的大小,即要找到它在最后的乘 ...

  2. CF #589 (Div. 2)C. Primes and Multiplication 快速幂+质因数

    题目链接:https://www.luogu.org/problem/CF1228C 问题可以转化为:求质数 $p$ 在 $1\sim n$ 中的每个数中的次幂之和. 因为 $p$ 是一个质数,只能由 ...

  3. Codeforces Round #589 (Div. 2) C - Primes and Multiplication(数学, 质数)

    链接: https://codeforces.com/contest/1228/problem/C 题意: Let's introduce some definitions that will be ...

  4. Codeforces 1228C. Primes and Multiplication

    传送门 当然是考虑 $n$ 的每个质数 $p$ 对答案的贡献 考虑 $p^k$ 在 $[1,m]$ 中出现了几次,显然是 $\left \lfloor \frac{m}{p^k} \right \rf ...

  5. codeforces C. Primes and Multiplication(快速幂 唯一分解定理)

    题目链接:http://codeforces.com/contest/1228/problem/C 题解:给定一个函数f,g,题目有描述其中的表达式含义和两者之间的关系. 然后计算: 首先把给定的x用 ...

  6. Codeforces Round #589 (Div. 2)

    目录 Contest Info Solutions A. Distinct Digits B. Filling the Grid C. Primes and Multiplication D. Com ...

  7. Codeforces Round #589 (Div. 2) (e、f没写)

    https://codeforces.com/contest/1228/problem/A A. Distinct Digits 超级简单嘻嘻,给你一个l和r然后寻找一个数,这个数要满足的条件是它的每 ...

  8. SPOJ PGCD 4491. Primes in GCD Table && BZOJ 2820 YY的GCD (莫比乌斯反演)

    4491. Primes in GCD Table Problem code: PGCD Johnny has created a table which encodes the results of ...

  9. SPOJ4491. Primes in GCD Table(gcd(a,b)=d素数,(1&lt;=a&lt;=n,1&lt;=b&lt;=m))加强版

    SPOJ4491. Primes in GCD Table Problem code: PGCD Johnny has created a table which encodes the result ...

随机推荐

  1. B - Yet Another Palindrome Problem的简单方法

    You are given an array aa consisting of nn integers. Your task is to determine if aa has some subseq ...

  2. C 2012年笔试题

    1指出程序段中的错误:分析错误的原因,并进行修改 1.1函数 swap 将两个字符串(字符数组作实参,长度不超过 100)的内容进行交换 void swap(char *pa,char *pb) { ...

  3. 利用 MinIO 轻松搭建静态资源服务

    目录 1 引言 2 MinIO 简介 3 MinIO 运行与静态资源使用 3.1 MinIO 获取 3.2 MinIO 启动与运行 3.2.1 前台简单启动 3.2.2 后台指定参数运行 3.2.3 ...

  4. css网页重置样式表(多版本)

    Eric reset.css html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, ...

  5. Kubernetes(K8s) 安装(使用kubeadm安装Kubernetes集群)

    背景: 由于工作发生了一些变动,很长时间没有写博客了. 概述: 这篇文章是为了介绍使用kubeadm安装Kubernetes集群(可以用于生产级别).使用了Centos 7系统. 一.Centos7 ...

  6. java NIO理解分析与基本使用

    我前段时间的一篇博客java网络编程--多线程数据收发并行总结了服务端与客户端之间的收发并行实践.原理很简单,就是针对单一客户端,服务端起两个线程分别负责read和write操作,然后线程保持阻塞等待 ...

  7. 一文搞懂 ThreadLocal 原理

    当多线程访问共享可变数据时,涉及到线程间同步的问题,并不是所有时候,都要用到共享数据,所以就需要线程封闭出场了. 数据都被封闭在各自的线程之中,就不需要同步,这种通过将数据封闭在线程中而避免使用同步的 ...

  8. [noip模拟赛]某种数列问题<dp>

    某种数列问题  (jx.cpp/c/pas) 1000MS 256MB 众所周知,chenzeyu97有无数的妹子(阿掉!>_<),而且他还有很多恶趣味的问题,继上次纠结于一排妹子的排法以 ...

  9. spring中BeanPostProcessor之一:InstantiationAwareBeanPostProcessor(02)

    在上篇博客中写道了bean后置处理器InstantiationAwareBeanPostProcessor,只介绍了其中一个方法的作用及用法,现在来看postProcessBeforeInstanti ...

  10. C++ 趣图

    一.心形 1. http://mathworld.wolfram.com/HeartCurve.html #include<stdio.h> using namespace std; in ...