就是暴力嘛。。。很水的一个题。。。

不好意思交都。。。

#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(水题)的更多相关文章

  1. light oj 1035 - Intelligent Factorial Factorization 素因子分解

    1035 - Intelligent Factorial Factorization Given an integer N, you have to prime factorize N! (facto ...

  2. lightoj 1010 (水题,找规律)

    lightoj 1010 Knights in Chessboard 链接:http://lightoj.com/volume_showproblem.php?problem=1010 题意:国际象棋 ...

  3. LightOJ 1166 Old Sorting 置换群 或 贪心 水题

    LINK 题意:给出1~n数字的排列,求变为递增有序的最小交换次数 思路:水题.数据给的很小怎么搞都可以.由于坐标和数字都是1~n,所以我使用置换群求循环节个数和长度的方法. /** @Date : ...

  4. LightOJ 1065 - Number Sequence 矩阵快速幂水题

    http://www.lightoj.com/volume_showproblem.php?problem=1065 题意:给出递推式f(0) = a, f(1) = b, f(n) = f(n - ...

  5. Lightoj 1112 - Curious Robin Hood 【单点改动 + 单点、 区间查询】【树状数组 水题】

    1112 - Curious Robin Hood PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 64 MB ...

  6. sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

    n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you w ...

  7. hdu 1018:Big Number(水题)

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  8. HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

    Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...

  9. D - 楼下水题(kmp+Manacher)

    D - 楼下水题 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Statu ...

随机推荐

  1. mysql面试常见题目2

    Sutdent表的定义 字段名 字段描述 数据类型 主键 外键 非空 唯一 自增 Id 学号 INT(10) 是 否 是 是 是 sName 姓名 VARCHAR(20) 否 否 是 否 否 Sex ...

  2. 如何让mysql按照两个或多个字段排序

    我准备设计一个供求信息的表格,里边包含序号(id)(自动增量),发布日期(time),上次更新(last_time).因为考虑到避免有人不停的重复发布信息来占据前列位置所以设置了last_time这个 ...

  3. 导入Cardboard SDK后Build到安卓平台出错:Unable to merge android manifests. (已解决)

    报错说“Unable to merge android manifests. See the consoler for more details.” 解决方法: 打开SDK Manager ,安装An ...

  4. 《图解 HTTP 》阅读 —— 第一章

    第1章 了解web及网络基础 计算机与网络设备相互通信的规则称为协议,比如:如何探测到通信目标.由哪一边发起通信.使用那种语言进行通信.怎么结束通信等. TCP/IP 协议族按照层次分为以下四层:应用 ...

  5. docker私服搭建nexus3

    docker私服搭建有官方的registry镜像,也有改版后的NexusOss3.x,因为maven的原因搭建了nexus,所以一并将docker私服也搭建到nexus上. nexus的安装过程就单独 ...

  6. python3之三级菜单

    city = { "江苏省": { "南京市": { "栖霞区": ["aa", "bb"], &q ...

  7. ats缓存规则

    一. 用户访问过程:1. ats收到一个用户对web对象的请求;2. 使用该地址, ats尝试着在其对象数据库(缓存)中用被请求对象的地址来定位该对象;3. 如果对象在缓存中, ats会检查该对象是否 ...

  8. Redis的C语言客户端(hiredis)的安装和使用

    关键词:hiredis, cRedis, redis clients, redis客户端, C客户端, 华为云分布式缓存服务 hiredis是一个非常全面的C语言版redis接口库,支持所有命令.管道 ...

  9. vue项目部署流程

    用vue-cli搭建的做法1.npm run build2.把dist里的文件打包上传至服务器 例 /data/www/,我一般把index.html放在static里所以我的文件路径为:/data/ ...

  10. mail邮件详解

    基础命令学习目录首页 1.配置   vim /etc/mail.rc文件尾增加以下内容 set from=1968089885@qq.com smtp="smtp.qq.com"s ...