light oj 1341 Aladdin and the Flying Carpet
来源:互联网 发布:药智网数据库 编辑:程序博客网 时间:2024/06/02 05:10
It's said that Aladdin had to solve seven mysteries beforegetting the Magical Lamp which summons a powerful Genie. Here we are concernedabout the first mystery.
Aladdin was about to enter to a magical cave, led by theevil sorcerer who disguised himself as Aladdin's uncle, found a strange magicalflying carpet at the entrance. There were some strange creatures guarding theentrance of the cave. Aladdin could run, but he knew that there was a highchance of getting caught. So, he decided to use the magical flying carpet. Thecarpet was rectangular shaped, but not square shaped. Aladdin took the carpetand with the help of it he passed the entrance.
Now you are given the area of the carpet and the length ofthe minimum possible side of the carpet, your task is to find how many types ofcarpets are possible. For example, the area of the carpet 12, and the minimumpossible side of the carpet is 2, then there can be two types of carpets andtheir sides are: {2, 6} and {3, 4}.
Input
Input starts with an integer T (≤ 4000),denoting the number of test cases.
Each case starts with a line containing two integers:ab (1 ≤ b ≤ a ≤ 1012) where adenotes the area of the carpet andb denotes the minimum possible sideof the carpet.
Output
For each case, print the case number and the number ofpossible carpets.
#include<iostream>#include<algorithm>#include<cmath>#include<cstdio>#include<queue>#include<cstring>#include<string>#include<map>#include<set>using namespace std;typedef long long ll;#define for1(i,a) for(int (i)=1;(i)<=(a);(i)++)#define for0(i,a) for(int (i)=0;(i)<(a);(i)++)#define sf scanf#define pf printf#define mem(i,a) memset(i,a,sizeof i)#define pi acos(-1.0)#define eps 1e-10const int Max=1e6+10;int cou,a,b,p[Max],x;bool vis[Max];ll m,n,ans;void prime()//素数打表{ cou=0; mem(vis,0); for(int i=2;i<=Max;i++) { if(!vis[i])p[cou++]=i; for(int j=0;j<cou&&i*p[j]<=Max;j++) { vis[i*p[j]]=1; if(!(i%p[j]))break; } }}void fenjie()//唯一分解定理{ ans=1; ll h=m; for(int i=0;i<cou&&(ll)p[i]*p[i]<=h;i++) { int num=0; if(!(h%p[i])) while(!(h%p[i])) num++,h/=p[i];//素因式的个数 ans*=(num+1); } if(h>1) ans*=2;}int main(){ prime(); sf("%d",&x); for1(i,x) { sf("%lld%lld",&m,&n); if(m<n*n) pf("Case %d: 0\n",i); else { fenjie(); ans>>=1; for(int i=1;i<n;i++) if(!(m%i))//不满足a,b>=n的数 ans--; pf("Case %d: %lld\n",i,ans); } } return 0;}
- Light OJ 1341 Aladdin and the Flying Carpet
- light oj 1341 Aladdin and the Flying Carpet
- Aladdin and the Flying Carpet Light OJ 1341
- Light OJ Aladdin and the Flying Carpet(约数个数)
- Light OJ 1341 Aladdin and the Flying Carpet Pollard_rho整数分解+DFS
- Light OJ 1341 Aladdin and the Flying Carpet(唯一分解定理)
- [整数分解+dfs] light oj 1341 Aladdin and the Flying Carpet
- Light OJ 1341 Aladdin and the Flying Carpet(算数基本定理)
- Light OJ 1341 Aladdin and the Flying Carpet(算数基本定理)
- lightOJ 1341 Aladdin and the Flying Carpet
- LightOJ 1341 Aladdin and the Flying Carpet
- LightOJ 1341Aladdin and the Flying Carpet
- LightOJ 1341 - Aladdin and the Flying Carpet
- LightOJ 1341 Aladdin and the Flying Carpet
- Aladdin and the Flying Carpet
- Aladdin and the Flying Carpet
- Aladdin and the Flying Carpet
- LightOJ 1341 - Aladdin and the Flying Carpet【合数分解】
- web配置文件属性metadata-complete讲解
- 欢迎使用CSDN-markdown编辑器
- Android Library工程switch case中使用 R.id.x报错
- 百度APi
- Android BLE虚拟设备端
- light oj 1341 Aladdin and the Flying Carpet
- 2017西安交大ACM小学期 美妙音乐[差分KMP匹配]
- 布谷鸟算法(cuckoo_search)可能会遇到的问题
- 为什么要使用CMake+VS编译OpenCV的源码
- Qt 常用类 —— QFont
- POJ1724
- JZOJ 3929. 【NOIP2014模拟11.6】创世纪
- 排序算法——直接选择排序
- Spring Aop源码学习--JoinPoint连接点