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. 【C++】Strassen算法代码

    本文仅代码,无理论解释 实话实说,我觉得这个算法在C系列的语言下,简直垃圾到爆炸--毕竟是一群完全不懂程序数学家对着纸弄出来的,看起来好像非常的有用,实际上耗时是非常爆炸的. 但是<算法导论&g ...

  2. Swagger2在DBA Service中生成RESTful API的实践

    目的与背景: 目的:对外暴露DBA Service必要的RESTful API,形成规整的API文档 背景:DBA Service后端采用Spring-boot,属于Spring家族,故生成API的工 ...

  3. Android通知栏前台服务

    一.前台服务的简单介绍 前台服务是那些被认为用户知道且在系统内存不足的时候不允许系统杀死的服务.前台服务必须给状态栏提供一个通知,它被放到正在运行(Ongoing)标题之下--这就意味着通知只有在这个 ...

  4. 面试都在问的「微服务」「RPC」「服务治理」「下一代微服务」一文带你彻底搞懂!

    ❝ 文章每周持续更新,各位的「三连」是对我最大的肯定.可以微信搜索公众号「 后端技术学堂 」第一时间阅读(一般比博客早更新一到两篇) ❞ 单体式应用程序 与微服务相对的另一个概念是传统的「单体式应用程 ...

  5. ionic中select下拉框点击无反应解决办法

    两种解决办法: 1.在select外的div加入属性 data-tap-disabled=”true” 2.找到ionic.bundle.js文件 的下面这个函数,添加如图两行代码  

  6. 【cs224w】Lecture 4 - 社区结构

    Community 转自本人:https://blog.csdn.net/New2World/article/details/105328390 之前讲到了网络中节点扮演不同角色,而角色这个概念和社区 ...

  7. 《Three.js 入门指南》3.1.1 - 基本几何形状 - 球体(SphereGeometry)

    3.1 基本几何形状 球体(SphereGeometry) 构造函数: THREE.SphereGeometry(radius, segmentsWidth, segmentsHeight, phiS ...

  8. XSS之绕过WAF总结

    来源<XSS跨站脚本攻击剖析与防御>&<WEB前端技术揭秘> 一.一般测试方法 步骤: 0.总则:见框就插 1.在输入框随便输入一些简单的字符,如 aaa,方便后续查找 ...

  9. Spring Taco Cloud——Controller的创建(含SpringMVC执行过程&SpringBoot&Spring三者解释及关联)

    在记录这次控制器编写前,对于Spring的感觉就是经常提这样代码好简洁,这样好方便,这个是用来干嘛的诸如之类的话. What is Spring ?这是我想问自己的,一直认为是简化代码利于工程的开源框 ...

  10. PHP的运行方式(SAPI)

    PHP 常量 PHP_SAPI 具有和 php_sapi_name() 相同的值. define('IS_CGI',(0 === strpos(PHP_SAPI,'cgi') || false !== ...