【Codeforces 992B】Nastya Studies Informatics
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
因为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的更多相关文章
- Nastya Studies Informatics CodeForces - 992B (大整数)
B. Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- Nastya Studies Informatics
Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes in ...
- CF992B Nastya Studies Informatics 数学(因子) 暴力求解 第三道
Nastya Studies Informatics time limit per test 1 second memory limit per test 256 megabytes input st ...
- 【55.70%】【codeforces 557A】Ilya and Diplomas
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【35.02%】【codeforces 734A】Vladik and flights
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- Linux 系统管理命令 - uptime - 显示系统的运行时间及负载
命令详解 重要星级: ★★★☆☆ 功能说明: uptime 命令可以输出当前系统时间.系统开机到现在的运行时间.目前有多少用户在线和系统平均负载等信息 语法格式: uptime 说明: 直接执行 up ...
- Spring通过注解注入有参
1.通过注解方式注入有参的构造函数 把@Autowired注解放在构造函数上方,在构造函数里写上需要注入的形参即可 2.通过XML配置文件方式定义有参构造函数
- E20171229-hm
specification n. 规格; 说明书; 详述;
- hdu 模拟 贪心 4550
卡片游戏 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...
- 状压DP UVA 11795 Mega Man's Mission
题目传送门 /* 题意:洛克人有武器可以消灭机器人,还可以从被摧毁的机器人手里得到武器,问消灭全部机器人的顺序总数 状态压缩DP:看到数据只有16,就应该想到状压(并没有).因为是照解题报告写的,代码 ...
- 392 Is Subsequence 判断子序列
给定字符串 s 和 t ,判断 s 是否为 t 的子序列.你可以认为 s 和 t 中仅包含英文小写字母.字符串 t 可能会很长(长度 ~= 500,000),而 s 是个短字符串(长度 <=10 ...
- 用Martini、websocket实现单机版聊天室
ChatRoom A stand-alone ChatRoom in Martini Please Star https://github.com/renleimlj/ChatRoom Interfa ...
- python模块中的__all__属性
转自:http://blog.csdn.net/sxingming/article/details/52903377 python模块中的__all__属性,可用于模块导入时限制,如:from mod ...
- 面试中的一些小问题之html5和html4的区别?
HTML5建立的一些新规则: 新特性应该基于HTML.CSS.DOM.JavaScript: 减少对外部插件的需求,如flash将会用video标签和audio标签代替: 更加优秀的错误处理: 更多取 ...
- bower——基本使用
基本概念 bower可以解决项目的静态文件依赖的问题 bower是用nodejs开发的,所以要现状nodejs 安装nodejs应用程序,网上自行下载 检验是否成功安装,打开电脑cmd,执行node ...