steve 学完了快速幂,现在会他快速的计算:(ij)%d , Alex 作为一个数学大师,给了 steve 一个问题:已知
i∈[1,n],j∈[1,m] ,计算满足 (ij)%d=0 的 (i,j) 的对数。

输入格式

T组输入,对于每一组输入三个数n,m,d。
(1≤T≤1000,1≤n,m,d≤109)。

输出格式

对于每组输入,输出答案,每个答案占一行。

样例

input
4
3 10 7
3 5 3
10 30 6
100 100 8
output
0
5
30
4937
不太懂,,先记下来再说
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll qpow(ll a,ll b){
ll ans=;
while(b){
if(b&) ans=(ans*a);
a=(a*a);
b>>=;
}
return ans;
}
int main(){
int T;scanf("%d",&T);
while(T--){
ll n,m,d;
scanf("%lld %lld %lld",&n,&m,&d);
vector<pair<ll,ll> > prs;
vector<pair<ll,ll> >::iterator it;
for(ll i=;i*i<=d;i++){
if(d%i==){
long long cnt=;
while(d%i==){
d/=i;cnt++;
}
prs.push_back({i,cnt});
}
}
ll res=;
if(d!=) prs.push_back({d,});
for(ll j=;j<=min(m,1LL*);j++){
ll g=;
// for(auto v:prs)
for(it=prs.begin();it!=prs.end();it++)
{
g*=qpow( it->first,( it->second+j-)/j);
}
if(j==) res+=(m-)*(n/g);
else res+=n/g;
}
printf("%lld\n",res);
}
return ;
}

. Number throry的更多相关文章

  1. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  2. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  3. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  4. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  5. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  6. iOS---The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  7. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  8. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

  9. [LeetCode] Number of Boomerangs 回旋镖的数量

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...

随机推荐

  1. (一)iview的校验TypeError: Cannot read property 'validateField' of undefined"

    一.问题描述 我是在自己封装了一个地址级联选择,然后想要每次改变了其中数据的时候,就进行一次单独校验,所以用到了iview对部分表单字段进行校验的方法validateField.其实一开始使用的时候是 ...

  2. Ubuntu16.04下安装搜狗输入法及实现中英文转换问题

    1.问题描述 版本信息:Ubuntu16.04 解决问题:搜狗输入法的安装 2.解决办法 STEP1:搜索搜狗输入法for Linux --> 选择64bit --> 下载得到一个sogo ...

  3. 数据科学中需要知道的5个关于奇异值分解(SVD)的应用

    介绍 "Another day has passed, and I still haven't used y = mx + b." 这听起来是不是很熟悉?我经常听到我大学的熟人抱怨 ...

  4. 一文上手Tensorflow2.0(四)

    系列文章目录: Tensorflow2.0 介绍 Tensorflow 常见基本概念 从1.x 到2.0 的变化 Tensorflow2.0 的架构 Tensorflow2.0 的安装(CPU和GPU ...

  5. oracle 10.1-10.4版本的oracle数据库要求

    1.针对arcgis 10.1的oracle数据库要求 受支持的数据库版本 标准版/标准独立版/企业版: Oracle 10g R2(64 位)10.2.0.3 Oracle 11g R1(64 位) ...

  6. VBScript - 动态 Array 实现方法大全!

    记录一些方法,关于 VBScript 中,动态 Array 的实现 ,也适用于 VBA, 很久以前,写 VBA 的时候,就觉得使用 Array 很不方便,因为大小固定, 当时想的是,要是 Array ...

  7. .NET Core技术研究-中间件的由来和使用

    我们将原有ASP.NET应用升级到ASP.NET Core的过程中,会遇到一个新的概念:中间件. 中间件是ASP.NET Core全新引入的概念.中间件是一种装配到应用管道中以处理请求和响应的软件.  ...

  8. c语言提取浮点型数据的整数部分与小数部分几种方法

    一 前记 最近涉及到把各种传感器的数据通过wifi和bt传输出去,这就涉及到了浮点传输的问题,为了方便传输,笔者的做法一般是把小数和整数部分分开,分别传输,这就比较简单明晰了. 二 方法论 其实,把浮 ...

  9. Django-利用Form组件和ajax实现的注册

    利用Form组件和ajax实现的注册 一.注册相关的知识点 1.Form组件 我们一般写Form的时候都是把它写在views视图里面,那么他和我们的视图函数也不影响,我们可以吧它单另拿出来,在应用下面 ...

  10. B 雷诺与奴隶主

    时间限制 : 5000 MS   空间限制 : 524288 KB 问题描述 自从周文武老师在班上吹嘘了"录试"这款游戏之后,PHD同学沉迷于其中无法自拔. "录试&qu ...