LightOJ - 1341唯一分解定理
唯一分解定理
先分解面积,然后除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唯一分解定理的更多相关文章
- LightOJ 1341 唯一分解定理
Aladdin and the Flying Carpet Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%lld &a ...
- Aladdin and the Flying Carpet LightOJ 1341 唯一分解定理
题意:给出a,b,问有多少种长方形满足面积为a,最短边>=b? 首先简单讲一下唯一分解定理. 唯一分解定理:任何一个自然数N,都可以满足:,pi是质数. 且N的正因子个数为(1+a1)*(1+a ...
- LightOJ - 1236 (唯一分解定理)
题意:求有多少对数对(i,j)满足lcm(i,j) = n,1<=i<=j, 1<=n<=1e14. 分析:根据整数的唯一分解定理,n可以分解为(p1^e1)*(p2^e2)* ...
- lightoj 1220 唯一分解定理
#include<bits/stdc++.h> using namespace std; #define maxn 1000005 #define ll long long int v[m ...
- LightOJ 1341 - Aladdin and the Flying Carpet (唯一分解定理 + 素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 Aladdin and the Flying Carpet Time Limit:3000 ...
- LightOJ 1341 Aladdin and the Flying Carpet(唯一分解定理)
http://lightoj.com/volume_showproblem.php?problem=1341 题意:给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. 思路 ...
- LightOJ - 1341 Aladdin and the Flying Carpet 唯一分解定理LightOJ 1220Mysterious Bacteria
题意: ttt 组数据,第一个给定飞毯的面积为 sss,第二个是毯子的最短的边的长度大于等于这个数,毯子是矩形但不是正方形. 思路: 求出 sss 的所有因子,因为不可能是矩形,所以可以除以 222, ...
- 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. ...
- lightoj 1236 正整数唯一分解定理
A - (例题)整数分解 Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:32768KB 6 ...
随机推荐
- ugui中实现圆形按钮
实现圆形按钮,原本是使用 alphHitTestMinimumThreshold 改成重载IsRaycastLocationValid来实现,直接贴代码 using UnityEngine; usin ...
- 某游戏应用的redis 数据库结构设计(转)
add by zhj: 搜了一下作者,原来之前是网易的大牛.2011年的文章,有些老了,很多地方可以将string类型键转为hash类型,这样更节省内存,将key聚合在一起,也更简练. 原文:http ...
- 4.Data Types in the mongo Shell-官方文档摘录
总结: 1.MongoDB 的BSON格式支持额外的数据类型 2 Date 对象内部存储64位字节存整数,存储使用NumberLong()这个类来存,使用NumberInt()存32位整数,128位十 ...
- 汇编学习笔记(AT&T语法)
一个最基本的汇编程序如下所示: .section .data .section .text .globl _start _start: movl $, %eax # the number 1 is t ...
- Vue(6)- Vue-router进阶、单页面应用(SPA)带来的问题
一.Vue-router进阶 回顾学过的vue-router,并参考官方文档学习嵌套路由等路由相关知识. 二.单页面应用(SPA)带来的问题 1.虽然单页面应用有优点,但是,如果后端不做服务器渲染(h ...
- Java NIO2 File API介绍
Introduction to the Java NIO2 File API GitHub NIO2中的文件API是Java 7附带的Java平台的主要新功能之一,特别是新的文件系统API的一个子集以 ...
- Java中String.valueOf、toString、(String)的区别
原文地址http://blog.csdn.net/yangzhaomuma/article/details/51173138 原文地址https://www.cnblogs.com/xhyouyou/ ...
- HTML 2 (Day49)
一.table标签 http://www.cnblogs.com/shaojiafeng/p/7516741.html 二.form 表单属性 action:表单提交到哪.一般指向服务端一个程序,程序 ...
- 《Spring Boot 实战》随记
第一部分 Spring 4.x 1. Spring基础 略过 2. Spring常用配置 2.1 Bean的scope 使用@Scope注解配置scope.默认signleton,原型模式protot ...
- ruby underscore
“examScore".underscore : exam_score "ExamScore".underscore: exam_score