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 ...
随机推荐
- day01_概念
1 网络分类: 1 按照范围: - 局域网:范围很小的网络,如一间办公室,一个公司 - 城域网:大致城市范围内的网络,半径几公里到几十公里 - 广域网:比城域网范围更大的 2 网络衡量标准 1 传输速 ...
- PHP has encountered an Access Violation at 01F4A622解决方法
php搭建的网站出现以下问题的解决方法分享: Z-blog,DedeCMS,Dsicuz!,PhpWind,PhpCMS,帝国CMS等都有可能出现php访问冲突问题. 今天访问网站发现出现了一个错误& ...
- sqli-labs学习笔记 DAY4
DAY 4 sqli-labs lesson 23 与lesson 1一样,只不过屏蔽了#和–注释符. 报错型注入: 爆库:id=99' UNION SELECT 1,extractvalue(1,c ...
- Hands on Machine Learning with Sklearn and TensorFlow学习笔记——机器学习概览
一.什么是机器学习? 计算机程序利用经验E(训练数据)学习任务T(要做什么,即目标),性能是P(性能指标),如果针对任务T的性能P随着经验E不断增长,成为机器学习.[这是汤姆米切尔在1997年定义] ...
- 深入理解Java类加载器(ClassLoader) (转)
转自: http://blog.csdn.net/javazejian/article/details/73413292 关联文章: 深入理解Java类型信息(Class对象)与反射机制 深入理解Ja ...
- ubuntu16更新源
http://blog.csdn.net/fengyuzhiren/article/details/54844870
- linux, configure --prefix 的作用
指定安装路径不指定prefix,则可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc.其它的资源文件放在/usr ...
- comet4j推送 405/500 JSON转换异常
因为Comet4J工作在NIO方式下,所以我们需要调整服务器连接器配置,更换为NOI连接器. 打开server.xml文件将找到原先的连接器配置: <Connector executor=&qu ...
- git 提交本地文件,删除文件夹,修改文件等
1. 下载git工具包 链接: https://git-scm.com/download/win 2. 右键打开git bash 登陆到自己的github账户 $ git config --globa ...
- [建树(非二叉树)] 1090. Highest Price in Supply Chain (25)
1090. Highest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors ...