array(2) { ["docs"]=> array(10) { [0]=> array(10) { ["id"]=> string(3) "428" ["text"]=> string(77) "Visual Studio 2017 单独启动MSDN帮助(Microsoft Help Viewer)的方法" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(8) "DonetRen" ["tagsname"]=> string(55) "Visual Studio 2017|MSDN帮助|C#程序|.NET|Help Viewer" ["tagsid"]=> string(23) "[401,402,403,"300",404]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400964" ["_id"]=> string(3) "428" } [1]=> array(10) { ["id"]=> string(3) "427" ["text"]=> string(42) "npm -v;报错 cannot find module "wrapp"" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "zzty" ["tagsname"]=> string(50) "node.js|npm|cannot find module "wrapp“|node" ["tagsid"]=> string(19) "[398,"239",399,400]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400760" ["_id"]=> string(3) "427" } [2]=> array(10) { ["id"]=> string(3) "426" ["text"]=> string(54) "说说css中pt、px、em、rem都扮演了什么角色" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(12) "zhengqiaoyin" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400640" ["_id"]=> string(3) "426" } [3]=> array(10) { ["id"]=> string(3) "425" ["text"]=> string(83) "深入学习JS执行--创建执行上下文(变量对象,作用域链,this)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "Ry-yuan" ["tagsname"]=> string(33) "Javascript|Javascript执行过程" ["tagsid"]=> string(13) "["169","191"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511399901" ["_id"]=> string(3) "425" } [4]=> array(10) { ["id"]=> string(3) "424" ["text"]=> string(30) "C# 排序技术研究与对比" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "vveiliang" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(8) ".Net Dev" ["catesid"]=> string(5) "[199]" ["createtime"]=> string(10) "1511399150" ["_id"]=> string(3) "424" } [5]=> array(10) { ["id"]=> string(3) "423" ["text"]=> string(72) "【算法】小白的算法笔记:快速排序算法的编码和优化" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "penghuwan" ["tagsname"]=> string(6) "算法" ["tagsid"]=> string(7) "["344"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511398109" ["_id"]=> string(3) "423" } [6]=> array(10) { ["id"]=> string(3) "422" ["text"]=> string(64) "JavaScript数据可视化编程学习(二)Flotr2,雷达图" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "chengxs" ["tagsname"]=> string(28) "数据可视化|前端学习" ["tagsid"]=> string(9) "[396,397]" ["catesname"]=> string(18) "前端基本知识" ["catesid"]=> string(5) "[198]" ["createtime"]=> string(10) "1511397800" ["_id"]=> string(3) "422" } [7]=> array(10) { ["id"]=> string(3) "421" ["text"]=> string(36) "C#表达式目录树(Expression)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "wwym" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(4) ".NET" ["catesid"]=> string(7) "["119"]" ["createtime"]=> string(10) "1511397474" ["_id"]=> string(3) "421" } [8]=> array(10) { ["id"]=> string(3) "420" ["text"]=> string(47) "数据结构 队列_队列实例:事件处理" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "idreamo" ["tagsname"]=> string(40) "C语言|数据结构|队列|事件处理" ["tagsid"]=> string(23) "["246","247","248",395]" ["catesname"]=> string(12) "数据结构" ["catesid"]=> string(7) "["133"]" ["createtime"]=> string(10) "1511397279" ["_id"]=> string(3) "420" } [9]=> array(10) { ["id"]=> string(3) "419" ["text"]=> string(47) "久等了,博客园官方Android客户端发布" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(3) "cmt" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511396549" ["_id"]=> string(3) "419" } } ["count"]=> int(200) } 222 URAL 1748 The Most Complex Number - 爱码网

题目链接:https://vjudge.net/problem/11177

题目大意:

  求小于等于 n 的最大反素数。

分析:

  n <= 10^18,而前20个素数的乘积早超过10^18,因此可手动打素数表,再dfs寻找最大反素数。

代码如下:

 1 #pragma GCC optimize("Ofast")
 2 #include <bits/stdc++.h>
 3 using namespace std;
 4  
 5 #define INIT() std::ios::sync_with_stdio(false);std::cin.tie(0);
 6 #define Rep(i,n) for (int i = 0; i < (n); ++i)
 7 #define For(i,s,t) for (int i = (s); i <= (t); ++i)
 8 #define rFor(i,t,s) for (int i = (t); i >= (s); --i)
 9 #define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
10 #define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
11 #define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
12 #define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
13  
14 #define pr(x) cout << #x << " = " << x << "  "
15 #define prln(x) cout << #x << " = " << x << endl
16  
17 #define LOWBIT(x) ((x)&(-x))
18  
19 #define ALL(x) x.begin(),x.end()
20 #define INS(x) inserter(x,x.begin())
21  
22 #define ms0(a) memset(a,0,sizeof(a))
23 #define msI(a) memset(a,inf,sizeof(a))
24 #define msM(a) memset(a,-1,sizeof(a))
25 
26 #define MP make_pair
27 #define PB push_back
28 #define ft first
29 #define sd second
30  
31 template<typename T1, typename T2>
32 istream &operator>>(istream &in, pair<T1, T2> &p) {
33     in >> p.first >> p.second;
34     return in;
35 }
36  
37 template<typename T>
38 istream &operator>>(istream &in, vector<T> &v) {
39     for (auto &x: v)
40         in >> x;
41     return in;
42 }
43  
44 template<typename T1, typename T2>
45 ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
46     out << "[" << p.first << ", " << p.second << "]" << "\n";
47     return out;
48 }
49  
50 typedef long long LL;
51 typedef unsigned long long uLL;
52 typedef pair< double, double > PDD;
53 typedef pair< int, int > PII;
54 typedef pair< LL, LL > PLL;
55 typedef set< int > SI;
56 typedef vector< int > VI;
57 typedef map< int, int > MII;
58 typedef vector< LL > VL;
59 typedef vector< VL > VVL;
60 const double EPS = 1e-10;
61 const int inf = 1e9 + 9;
62 const LL mod = 1e9 + 7;
63 const int maxN = 5e5 + 7;
64 const LL ONE = 1;
65 const LL evenBits = 0xaaaaaaaaaaaaaaaa;
66 const LL oddBits = 0x5555555555555555;
67 
68 int T;
69 LL n;
70 PLL ans;
71 
72 int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
73 
74 // x 表示当前处理到第 x 个质数
75 // ret为当前选择下的质数乘积 
76 // pcnt 为 1~x-1 个质数中,每个质数选择数量+1的乘积 
77 // limit 表示第x个质数选则的上限 
78 // cnt表示第 x 个质数已经选了多少个 
79 inline void dfs(int x = 0, LL ret = 1, LL pcnt = 1, int limit = inf, int cnt = 0) {
80     if(ret > n || limit < cnt) return;
81     LL tmp = pcnt * (cnt + 1);
82     if(ans.sd < tmp || ans.sd == tmp && ans.ft > ret) ans = MP(ret, tmp);
83     
84     if(n / ret >= primes[x])dfs(x, ret * primes[x], pcnt, limit, cnt + 1); // 选 primes[x]
85     if(cnt) dfs(x + 1, ret, tmp, cnt, 0); // 不选 primes[x]
86 }
87 
88 int main(){
89     INIT();
90     cin >> T;
91     while(T--) {
92         cin >> n;
93         ans = MP(inf, -1);
94         dfs();
95         cout << ans.ft << " " << ans.sd << endl;
96     }
97     return 0;
98 }
View Code

相关文章: