C - Aladdin and the Flying Carpet
#include<bitset>
#include<map>
#include<vector>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#define inf 0x3f3f3f3f
#define mem(a,x) memset(a,x,sizeof(a)) using namespace std;
typedef long long ll; //输入挂
inline ll in()
{
ll res=;char c;
while((c=getchar())<'' || c>'');
while(c>='' && c<='')res=res*+c-'',c=getchar();
return res;
} const int N=;
ll prime[];
int p;
bitset<N> vis; void init()
{
for(int i=;i<N;i++)
{
if(!vis[i])
{
prime[p++]=i;
for(int j=i+i;j<N;j+=i)
{
vis[j]=;
}
}
}
}
int main()
{
int T = in();
int ii = ;
init();
while(T--)
{
ll area = in(),min_side = in();
if(min_side >= sqrt(area)){
printf("Case %d: %d\n",ii++,);
continue;
}
ll tmp = area;
int ans = ;
for(int i = ;i < p && prime[i]*prime[i] <= area;i++)
{
int cnt = ;
while(area%prime[i] == )
{
area /= prime[i];
cnt++;
}
ans *= (cnt+);
}
if(area != ) ans <<= ;
ans >>= ; //因数的个数除以二就是组数,同时排除了平方根
for(int i = ;i < min_side;i++)
if(tmp%i == ) ans--; //min_side此时是小于sqrt(area)的
printf("Case %d: %d\n",ii++,ans);
}
return ;
}
C - Aladdin and the Flying Carpet的更多相关文章
- LightOJ 1341 - Aladdin and the Flying Carpet (唯一分解定理 + 素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 Aladdin and the Flying Carpet Time Limit:3000 ...
- Aladdin and the Flying Carpet
Aladdin and the Flying Carpet https://cn.vjudge.net/contest/288520#problem/C It's said that Aladdin ...
- C - Aladdin and the Flying Carpet 有多少种长方形满足面积为a(<=10^12),且最短边>=b;长方形边长为整数,且一定不可以是正方形。
/** 题目:C - Aladdin and the Flying Carpet 链接:https://vjudge.net/contest/154246#problem/C 题意:有多少种长方形满足 ...
- LightOJ1341 Aladdin and the Flying Carpet —— 唯一分解定理
题目链接:https://vjudge.net/problem/LightOJ-1341 1341 - Aladdin and the Flying Carpet PDF (English) S ...
- Aladdin and the Flying Carpet (LightOJ - 1341)【简单数论】【算术基本定理】【分解质因数】
Aladdin and the Flying Carpet (LightOJ - 1341)[简单数论][算术基本定理][分解质因数](未完成) 标签:入门讲座题解 数论 题目描述 It's said ...
- 数论 C - Aladdin and the Flying Carpet
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a ...
- E - Aladdin and the Flying Carpet
It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a ...
- [LightOJ 1341] Aladdin and the Flying Carpet (算数基本定理(唯一分解定理))
题目链接: https://vjudge.net/problem/LightOJ-1341 题目描述: 问有几种边长为整数的矩形面积等于a,且矩形的短边不小于b 算数基本定理的知识点:https:// ...
- 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. ...
- LightOJ 1341 Aladdin and the Flying Carpet 数学
题意:给个矩形的面积a,和矩形的最小边长b,问有多少种矩形的方案(不能是正方形) 分析:a可以写成x,y,因为不能是正方形,所以设x<y,那么x<sqrt(a),y>sqrt(a) ...
随机推荐
- Linux环境下安装MySQL(yum方式)
1.下载mysql源安装包shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 安装my ...
- Java其实不支持垃圾回收
Java其实不支持垃圾回收.如果真的支持的话,大多数Java程序在运行的一开始就应该把程序本身删除,因为这些程序本身就是垃圾. // TODO: This is a 分割线. Please no ...
- selenium2 python范例
selenium2 python范例 下面脚本的功能是:打开谷歌浏览器-->跳转到某个网址-->输入用户名和密码登录-->读取页面内的数据并求和. # coding=utf-8 #编 ...
- 使用官方Android-support-v7在低版本上使用ActionBarActivity
昨天晚上更新了下Android SDK Manager,发现Extras下的Android Support Library已经更新到19.1了,上网一查原来是sdk\extras\android\su ...
- Java 使用POI操作EXCEL及测试框架搭建、测试开发的一些想法
无论是UI自动化测试还是接口自动化测试都需要进行数据驱动,一般很常见的一种方式就是用excel来管理数据,那么就涉及到一些代码对EXCEL的操作,之前我们介绍过用CSV来处理EXCEL,但是它的功能还 ...
- LDAP解释(转)
我要着重指出,LDAP是一个数据库,但是又不是一个数据库.说他是数据库,因为他是一个数据存储的东西.但是说他不是数据库,是因为他的作用没有数据库这么强大,而是一个目录. 为了理解,给一个例子就是电话簿 ...
- typeof详解
typeof operator 返回了表示对象类型的字符串 下表列出了typeof可能的返回值. Type Result Undefined "undefined" Null &q ...
- 什么是HTTP协议?
HTTP协议(超文本传输协议)位于TCP/IP协议栈的应用层.传输层采用面向连接的TCP HTTP请求详细过程
- PIL 安装及使用
我ubunto虚拟机自带的是python2.7,好像PIL也只支持到2.7. PIL包的安装 Debian/Ubunto Linux下直接安装: sudo apt-get install python ...
- CodeForces - div1 -650D:Zip-line(主席树 占位)
(和南京那题很像,比赛的时候就两个队A了.我们队找到了思路,但是花了1个多小时没有写出来,emmmm,我的锅,当时线段树写丑了. 题意:给定数组,Q次询问,假设把第i个大小hi改为b,求最长上升子序列 ...