Intelligent Factorial Factorization LightOJ - 1035(水题)
就是暴力嘛。。。很水的一个题。。。
不好意思交都。。。
#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 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 maxn = , INF = 0x7fffffff;
int primes[maxn], base[maxn], mi[maxn];
int vis[maxn];
int ans = ;
set<int> s;
void init()
{
mem(vis, );
for(int i=; i<maxn; i++)
{
if(vis[i]) continue;
primes[ans++] = i;
for(LL j=(LL)i*i; j<maxn; j+=i)
vis[j] = ;
}
} int main()
{
init();
int T, kase = ;
scanf("%d",&T);
while(T--)
{
s.clear();
mem(base, ); int n;
scanf("%d",&n);
for(int i=; i<=n; i++)
{
int temp = i;
for(int j=; j<ans && primes[j] * primes[j] <= temp; j++)
{
while(temp % primes[j] == )
{
temp /= primes[j];
base[primes[j]]++;
}
if(base[primes[j]] > )
{
s.insert(primes[j]);
}
}
if(temp > )
{
base[temp]++;
s.insert(temp);
}
}
printf("Case %d: %d = ",++kase, n);
int cnt = ;
for(set<int>::iterator it=s.begin(); it!=s.end(); it++)
{
if(cnt == )
printf("%d (%d)",*it, base[*it]);
else
printf(" * %d (%d)",*it, base[*it]);
cnt++;
}
printf("\n"); } return ;
}
Intelligent Factorial Factorization LightOJ - 1035(水题)的更多相关文章
- light oj 1035 - Intelligent Factorial Factorization 素因子分解
1035 - Intelligent Factorial Factorization Given an integer N, you have to prime factorize N! (facto ...
- lightoj 1010 (水题,找规律)
lightoj 1010 Knights in Chessboard 链接:http://lightoj.com/volume_showproblem.php?problem=1010 题意:国际象棋 ...
- LightOJ 1166 Old Sorting 置换群 或 贪心 水题
LINK 题意:给出1~n数字的排列,求变为递增有序的最小交换次数 思路:水题.数据给的很小怎么搞都可以.由于坐标和数字都是1~n,所以我使用置换群求循环节个数和长度的方法. /** @Date : ...
- LightOJ 1065 - Number Sequence 矩阵快速幂水题
http://www.lightoj.com/volume_showproblem.php?problem=1065 题意:给出递推式f(0) = a, f(1) = b, f(n) = f(n - ...
- Lightoj 1112 - Curious Robin Hood 【单点改动 + 单点、 区间查询】【树状数组 水题】
1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 MB ...
- sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)
n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you w ...
- hdu 1018:Big Number(水题)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)
Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...
- D - 楼下水题(kmp+Manacher)
D - 楼下水题 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Statu ...
随机推荐
- idou老师教你学Istio:如何用 Istio 实现速率限制
使用 Istio 可以很方便地实现速率限制.本文介绍了速率限制的使用场景,使用 memquota\redisquota adapter 实现速率限制的方法,通过配置 rule 实现有条件的速率限制,以 ...
- Unity萌新日记—开发小技巧与冷知识(脚本篇)
在学习unity的过程中,总会遇到很多零碎的知识点和小技巧,在此把它们记录下来,方便日后查看. 第一篇是关于脚本的一些你可能不知道的小知识. 还是个正在学习的萌新,如果写的不好,请谅解. Unity版 ...
- Datasets
STL-10 https://cs.stanford.edu/~acoates/stl10/ CIFAR-10 and CIFAR-100 https://www.cs.toronto.edu/~kr ...
- js中 null, undefined, 0,空字符串,false,不全等比较
null == undefined // true null == '' // false null == 0 // false null == false // false undefined = ...
- 分布式高并发下全局ID生成策略
数据在分片时,典型的是分库分表,就有一个全局ID生成的问题.单纯的生成全局ID并不是什么难题,但是生成的ID通常要满足分片的一些要求: 1 不能有单点故障. 2 以时间为序,或者ID里包含时间 ...
- django_models后台管理myarya
arya重点代码 # urls.py from django.urls import path,re_path,include from arya.service import v1 urlpatte ...
- 更换 CentOS 7 的下载源为阿里云
http://blog.csdn.net/realghost/article/details/45949759
- java控制台编译通过,运行出现找不到或无法加载主类的情况
参考链接:http://www.knowsky.com/1046493.html 当建了一个包之后(假设建的包的名字为com),找到该java文件的com目录,发现编译能够通过,但是运行的时候出现了一 ...
- 【Alpha】技术规格说明书
由于第1周已经写过技术规格说明书(设计文档),本周更新了上一版内容. Github地址:https://github.com/buaase/Phylab-Web/blob/master/docs/Ba ...
- Task 10 统计从1到某个整数之间出现的1的次数
任务:给定一个十进制的正整数,写下从1开始,到N的所有整数,然后数一下其中出现“1”的个数. 要求: 写一个函数 f(N) ,返回1 到 N 之间出现的 “1”的个数.例如 f(12) = 5. 在3 ...