Aladdin and the Flying Carpet LightOJ - 1341 (素数打表 + 算术基本定理)
题意:
就是求a的因数中大于b的有几对
解析;
先把素数打表
运用算术基本定理 求出a的所有因数的个数
然后减去小于b的因数的个数
代码如下:
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define maxn 1100000
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int LL_INF = 0x7fffffffffffffff,INF = 0x3f3f3f3f;
LL primes[maxn];
bool vis[maxn];
LL ans = ;
void init()
{
mem(vis,);
for(int i=; i<maxn; i++)
if(!vis[i])
{
primes[ans++] = i;
for(LL j=(LL)i*i; j<maxn; j+=i)
vis[j] = ;
}
}
int main()
{
init();
int T, kase = ;
scanf("%d",&T);
LL a, b;
while(T--)
{
LL res = ;
scanf("%lld%lld",&a,&b);
if(a <= b*b) {printf("Case %d: 0\n",++kase);continue;}
LL x = a;
for(LL i=; i<ans && primes[i] * primes[i] <= a; i++)
{
LL cnt2 = ;
while(a % primes[i] == )
{
a /= primes[i];
cnt2++;
}
if(cnt2 > )
{
res *= (cnt2 + );
// if(primes[i] < b)
// ios *= (cnt2+1);
}
}
if(a > )
{
res *= ;
// if(a < b)
// ios *= 2;
}
res /= ;
for(int i=; i<b; i++)
if(x % i == )
res--;
printf("Case %d: %lld\n",++kase,res); } return ;
}
Aladdin and the Flying Carpet LightOJ - 1341 (素数打表 + 算术基本定理)的更多相关文章
- Aladdin and the Flying Carpet (LightOJ - 1341)【简单数论】【算术基本定理】【分解质因数】
Aladdin and the Flying Carpet (LightOJ - 1341)[简单数论][算术基本定理][分解质因数](未完成) 标签:入门讲座题解 数论 题目描述 It's said ...
- Aladdin and the Flying Carpet LightOJ 1341 唯一分解定理
题意:给出a,b,问有多少种长方形满足面积为a,最短边>=b? 首先简单讲一下唯一分解定理. 唯一分解定理:任何一个自然数N,都可以满足:,pi是质数. 且N的正因子个数为(1+a1)*(1+a ...
- LightOJ 1341 - Aladdin and the Flying Carpet (唯一分解定理 + 素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 Aladdin and the Flying Carpet Time Limit:3000 ...
- 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
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 题意:有多少种长方形满足 ...
- 1341 - Aladdin and the Flying Carpet ---light oj (唯一分解定理+素数筛选)
http://lightoj.com/volume_showproblem.php?problem=1341 题目大意: 给你矩形的面积(矩形的边长都是正整数),让你求最小的边大于等于b的矩形的个数. ...
- LightOJ 1341 - Aladdin and the Flying Carpet
题目链接:http://lightoj.com/volume_showproblem.php?problem=1341 题意:给你地毯面积和最小可能边的长度,让你求有几种组合的可能. 题解:这题就厉害 ...
- LightOJ - 1341 Aladdin and the Flying Carpet 唯一分解定理LightOJ 1220Mysterious Bacteria
题意: ttt 组数据,第一个给定飞毯的面积为 sss,第二个是毯子的最短的边的长度大于等于这个数,毯子是矩形但不是正方形. 思路: 求出 sss 的所有因子,因为不可能是矩形,所以可以除以 222, ...
随机推荐
- Spark运行时错误与解决
Spark java.io.IOException: Filesystem closed partition数量太小,读取数据后进行repartition重新分片再处理. Spark Streami ...
- 关于Http 传输二维json
传输一维的好说 public static String doPost(String url) { String result = new String(); OutputStream out = n ...
- Django框架知识点整理
1.安装django, pip install django 或者是通过 “==”符号指定版本号. 2.创建一个Django项目: django-admin createproject project ...
- Spring-bean的循环依赖以及解决方式
链接:https://blog.csdn.net/u010853261/article/details/77940767 https://www.jianshu.com/p/6c359768b1dc
- [开源 .NET 跨平台 Crawler 数据采集 爬虫框架: DotnetSpider] [四] JSON数据解析
[DotnetSpider 系列目录] 一.初衷与架构设计 二.基本使用 三.配置式爬虫 四.JSON数据解析与配置系统 五.如何做全站采集 场景模拟 接上一篇, JD SKU对应的店铺信息是异步加载 ...
- Linux ugo 权限
Linux 系统中文件的 ugo 权限是 Linux 进行权限管理的基本方式.本文将介绍 ugo 权限的基本概念.说明:本文的演示环境为 ubuntu 16.04. 文件的所有者和组 Linux 文件 ...
- ssh实现办公室电脑连接家中的电脑
友情提示:如果您不知道您家路由器管理页面的密码,请您忽略此文. 问题背景: 家中有台笔记本电脑,它是通过家中的路由器与外界联网的,这时,我想通过ssh服务让公司的电脑能连上我家中的笔记本. 可以画个图 ...
- 1017 B. The Bits
链接 [http://codeforces.com/contest/1017/problem/B] 题意 给你两个长度为n,包含0和1的字符串a和b,有一种操作swap a中的任意两个字符使得a&am ...
- 实验五 TCP传输及加密
实验内容: 1.运行教材上TCP代码,结对进行,一人服务器,一人客户端: 2.利用加解密代码包,编译运行代码,一人加密,一人解密: 3.集成代码,一人加密后通过TCP发送: 注:加密使用AES或者DE ...
- 读书笔记(chapter17)
设备类型:在所有Unix系统中为了统一普通设备的操作所采用的分类 模块:Linux内核中用于按需加载和卸载目标码的机制 内核对象:内核数据结构中支持面对对象的简单操作,还支持维护对象之间的父子关系 1 ...