【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

因为gcd(a,b)=x
所以设a = n*x b = m*x
又有a*b/gcd(a,b)=lcm(a,b)=y
则n*m*x = y
即n*(m*x)=y
所以枚举y的因子n
算出对应的y/n是否为x的倍数
如果是的话,则算出n,m的具体值
然后对于ab不加(避免重复计数)

【代码】

#include <bits/stdc++.h>
#define ll long long
using namespace std; ll l,r,x,y;
/*
a = n*x
b = m*x a*b/x = y
n*m*x = y
n*(m*x) = y
*/ bool in_range(ll x){
if (x>=l && x<=r) return true;
return false;
} int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> l >> r >> x >> y;
ll len = sqrt(y);
ll ans = 0;
for (ll n = 1;n <= len;n++)
if (y%n==0){
ll temp = y/n;
if (temp%x==0){
ll m = temp/x;
ll a = n*x;
ll b = m*x;
if (a>b) continue; if (__gcd(a,b)==x && in_range(a) && in_range(b)){
if (a==b) ans++;else ans+=2;
}
}
}
cout<<ans<<endl;
return 0;
}

【Codeforces 992B】Nastya Studies Informatics的更多相关文章

  1. Nastya Studies Informatics CodeForces - 992B (大整数)

    B. Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input ...

  2. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  3. Nastya Studies Informatics

    Nastya Studies Informatics   time limit per test 1 second   memory limit per test 256 megabytes   in ...

  4. CF992B Nastya Studies Informatics 数学(因子) 暴力求解 第三道

    Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input st ...

  5. 【55.70%】【codeforces 557A】Ilya and Diplomas

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【35.02%】【codeforces 734A】Vladik and flights

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  8. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  9. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

随机推荐

  1. url中传参数为中文的转码与解码解决方法

    1.转码 中文为 “你好”  var ProjectName = encodeURI(encodeURI("你好"));,如下图所示 跳转页面  window.location.h ...

  2. [TJOI2012]桥

    Description 有n个岛屿,m座桥,每座桥连通两座岛屿,桥上会有一些敌人,玩家只有消灭了桥上的敌人才能通过,与此同时桥上的敌人会对玩家造成一定伤害.而且会有一个大Boss镇守一座桥,以玩家目前 ...

  3. jQuery实现文字横向滚动效果

    HTML代码: <div id="aaa" style="width:100px; position:relative; white-space:nowrap; o ...

  4. 专题四:自定义Web浏览器

    前言: 前一个专题介绍了自定义的Web服务器,然而向Web服务器发出请求的正是本专题要介绍的Web浏览器,本专题通过简单自定义一个Web浏览器来简单介绍浏览器的工作原理,以及帮助一些初学者揭开浏览器这 ...

  5. (9)string对象上的操作2

    比较string对象的比较运算符 这种由string类定义的几种比较字符串的运算符能逐一比较string对象中的字符(对大小写敏感).

  6. Android Could not find com.afollestad:material-dialogs:0.7.6.0 解决

    AS报错:Could not find com.afollestad:material-dialogs:0.7.6.0 网上没有解决方案: 解决: 将用: compile('com.afollesta ...

  7. SugarCRM安装过程——PHP文件上传限制问题

    找到D:\xampp\php目录下,php文件中的php.ini文件,用写字板打开: 1.查找post_max_size,指通过表单POST给PHP的所能接收的最大值,包括表单里的所有值,默认为8M, ...

  8. DIV自动居中

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. SQL SERVER 2008 在某表中新增一列时失败

    背景:新增列语句如:“alter table 表名 add 列名 float default 0 with values”(用VS2010做网站,这句话是在C#代码里执行的) 报错提示: 警告: 已经 ...

  10. SqlBulkCopy实现大批量数据导入

    //自增列重新生成:SqlBulkCopy bc = new SqlBulkCopy(conn) //自增列保留原值:SqlBulkCopy bc = new SqlBulkCopy(conn,Sql ...