唯一分解定理

先分解面积,然后除2,再减去面积%长度==0的情况,注意毯子不能是正方形

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; bool vis[N];
ll prime[N],cnt;
void getprime()
{
cnt=;
memset(vis,,sizeof vis);
for(int i=;i<N;i++)
{
if(!vis[i])
{
prime[cnt++]=i;
for(int j=*i;j<N;j+=i)
vis[j]=;
}
}
}
ll getnum(ll x)
{
if(x==)return ;
ll ans=;
for(ll i=; i<cnt&&prime[i]*prime[i]<=x; i++)
{
ll k=;
while(x%prime[i]==){
x/=prime[i];
k++;
}
ans*=k;
}
if(x!=)ans*=;
ans/=;
return ans;
}
int main()
{
/* ios::sync_with_stdio(false);
cin.tie(0);*/
getprime();
int t,cnt=;
scanf("%d",&t);
while(t--){
ll a,b;
scanf("%lld%lld",&a,&b);
if(b*b>=a)
{
printf("Case %d: %lld\n",++cnt,);
continue;
}
ll ans=getnum(a);
for(ll i=;i<b;i++)
if(a%i==)
ans--;
printf("Case %d: %lld\n",++cnt,ans);
}
return ;
}
/*********************
2
10 2
12 2
*********************/

LightOJ - 1341唯一分解定理的更多相关文章

  1. LightOJ 1341 唯一分解定理

    Aladdin and the Flying Carpet Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%lld &a ...

  2. Aladdin and the Flying Carpet LightOJ 1341 唯一分解定理

    题意:给出a,b,问有多少种长方形满足面积为a,最短边>=b? 首先简单讲一下唯一分解定理. 唯一分解定理:任何一个自然数N,都可以满足:,pi是质数. 且N的正因子个数为(1+a1)*(1+a ...

  3. LightOJ - 1236 (唯一分解定理)

    题意:求有多少对数对(i,j)满足lcm(i,j) = n,1<=i<=j, 1<=n<=1e14. 分析:根据整数的唯一分解定理,n可以分解为(p1^e1)*(p2^e2)* ...

  4. lightoj 1220 唯一分解定理

    #include<bits/stdc++.h> using namespace std; #define maxn 1000005 #define ll long long int v[m ...

  5. LightOJ 1341 - Aladdin and the Flying Carpet (唯一分解定理 + 素数筛选)

    http://lightoj.com/volume_showproblem.php?problem=1341 Aladdin and the Flying Carpet Time Limit:3000 ...

  6. LightOJ 1341 Aladdin and the Flying Carpet(唯一分解定理)

    http://lightoj.com/volume_showproblem.php?problem=1341 题意:给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. 思路 ...

  7. LightOJ - 1341 Aladdin and the Flying Carpet 唯一分解定理LightOJ 1220Mysterious Bacteria

    题意: ttt 组数据,第一个给定飞毯的面积为 sss,第二个是毯子的最短的边的长度大于等于这个数,毯子是矩形但不是正方形. 思路: 求出 sss 的所有因子,因为不可能是矩形,所以可以除以 222, ...

  8. 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)

    http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. ...

  9. lightoj 1236 正整数唯一分解定理

    A - (例题)整数分解 Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB     6 ...

随机推荐

  1. 关于websocket

    一句话总结: websocket可以说是基于HTTP但有有所进化的一个介于应用层和传输层的接口抽象,不是协议. 1 需要基于HTTP进行3次握手,4次挥手(在握手期间建立websocket连接,不再通 ...

  2. python类的相关知识第二部分

    类的继承.多态.封装 一.类的继承 1.应用场景: 类大部分功能相同,大类包含小类的情况 例如: 动物类 共性:都要吃喝拉撒.都有头有脚 特性: 猫类.走了很轻,叫声特别,喜欢白天睡觉 狗类.的叫声很 ...

  3. jsp页面上读取MySQL数据库datetime时间显示问题

    mysql数据库中时间字段选用了datetime,如果通过java实现在jsp页面上显示时间为"年-月-日  时:分"等格式,那么如下代码就会有不同的结果! 实体类中两个变量: p ...

  4. C++对象模型那点事儿(布局篇)

    1 前言 在C++中类的数据成员有两种:static和nonstatic.类的函数成员由三种:static,nonstatic和virtual. 上篇我们尽量说一些宏观上的东西,数据成员与函数成员在类 ...

  5. 聊天软件项目UDP升级版

    import java.net.*; import java.io.*; class UdpSend2 { public static void main(String[] args) throws ...

  6. python中self cls init的理解

    原创文章,未经允许禁止转载! python中self cls init的理解 python中self cls init的理解

  7. Java并发(1):synchronized

    虽然多线程编程极大地提高了效率,但是也会带来一定的隐患.比如说两个线程同时往一个数据库表中插入不重复的数据,就可能会导致数据库中插入了相同的数据.今天我们就来一起讨论下线程安全问题,以及Java中提供 ...

  8. (转)CTO的烦恼:为啥差距就这么大呢?

    话说胖哒是一只CTO,近来遇到了一些小烦恼… 胖哒表示这么多问题想想就头大啊! 一直听说用Docker解决问题不错,于是两个月前,胖哒不远万里来到DockerCon 16,打算向国外的Docker先行 ...

  9. cdoj1344卿学姐种美丽的花

    地址:http://acm.uestc.edu.cn/#/problem/show/1344 题目: 卿学姐种美丽的花 Time Limit: 8000/4000MS (Java/Others)    ...

  10. nginx ip无法访问

    CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤. 1.关闭firewall: systemctl stop firewalld.service #停止f ...