【CS Round #43 E】Coprime Pairs
【链接】点击打开链接
【题意】
【题解】
【错的次数】
【反思】
【代码】
/*
N在const里面,可以改动;
求出2..N之间的所有质数;
放在zsb数组里面;
时间复杂度是O(N)的;
但是需要空间也是O(N)的;
*/ #include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <cstdlib>
#include <cmath>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x+1)
#define oi(x) printf("%d",x)
#define oc putchar(' ')
#define ol(x) printf("%lld",x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0) typedef pair<int, int> pii;
typedef pair<LL, LL> pll; const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 2e5;// bool iszs[N + 100];
vector <int> zsb;
int n,k; int main()
{
ms(iszs, true);
rep1(i, 2, N)
{
if (iszs[i]) zsb.pb(i);
int len = zsb.size();
rep1(j, 0, len - 1)
{
int t = zsb[j];
if (i*t>N) break;
iszs[i*t] = false;
if (i%t == 0) break;
}
}
//v[0] = 2,v[1] = 3;
ri(n), ri(k);
k = n*(n - 1) / 2 - k;
int t = 2;
while (t*(t - 1) / 2 <= k) {
t++;
}
t--;
rep1(i, 2, 2 + t - 1)
zsb[i] *= 2;
k = k - t*(t - 1) / 2;
if (k > 0) {
zsb[2 + t] *= 3;
rep1(i, 2, 2 + k - 1) zsb[i] *= 3;
}
rep1(i, 2, 2 + n - 1)
oi(zsb[i]), oc;
return 0;
}
【CS Round #43 E】Coprime Pairs的更多相关文章
- 【CS Round #43 D】Bad Triplet
[链接]点击打开链接 [题意] 给你n个点m条边的无权无向联通图; 让你找3个点A,B,C 使得A->B=B->C=A->C 这里X->Y表示点X到点Y的最短路长度. [题解] ...
- 【CS Round #43 C】Rectangle Partition
[链接]点击打开链接 [题意] 有一辆火车,它的长度为L,然后假设这辆车现在随机可能地出现在0..D之间,然后假设它已经耗光了油. 问你它需要走的期望距离是多少. 这里要走的距离指的是车里最近的加油站 ...
- 【CS Round #43 B】Rectangle Partition
[链接]https://csacademy.com/contest/round-43/task/rectangle-partition/ [题意] 水题 [题解] 横着过去,把相邻的边的宽记录下来. ...
- 【CS Round #43 A】Expected Dice
[链接]https://csacademy.com/contest/round-43/task/expected-dice/ [题意] 大水题 [题解] 把36种可能的结果都存下来. 然后把重复出现的 ...
- 【CS round 34】Minimize Max Diff
[题目链接]:https://csacademy.com/contest/round-34/task/minimize-max-diff/ [题意] 给你n个数字; 数组按顺序不下降; 让你删掉k个数 ...
- 【CS Round 34】Max Or Subarray
[题目链接]:https://csacademy.com/contest/round-34/summary/ [题意] 让你找一个最短的连续子串; 使得这个子串里面所有数字or起来最大; [题解] 对 ...
- 【CS Round #36 (Div. 2 only) A】Bicycle Rental
[题目链接]:https://csacademy.com/contest/round-36/task/bicycle-rental/ [题意] 让你从n辆车中选一辆车; 每一辆车有3个属性 1.到达车 ...
- 【CS Round #37 (Div. 2 only) D】Reconstruct Graph
[Link]:https://csacademy.com/contest/round-37/task/reconstruct-graph/statement/ [Description] 给你一张图; ...
- 【CS Round #37 (Div. 2 only) B】Group Split
[Link]:https://csacademy.com/contest/round-37/task/group-split/ [Description] 让你把一个数分成两个数a.b的和; (a,b ...
随机推荐
- SQLServer2008端口及防火墙设置
一,Microsoft SQL Server 2008R2数据库设置 1. 开始=>程序=>Microsoft SQL Server 2008R2=>配置工具=>S ...
- nuxt 关闭ESlint 语法检测
学习nuxt中在自己编写search组件的时候出现了各种类似于Expected indentation of 0 spaces but found 4的问题 上网搜是因为ESlint语法检测产生的问题 ...
- make---GNU编译工具
make命令是GNU的工程化编译工具,用于编译众多相互关联的源代码问价,以实现工程化的管理,提高开发效率. 知识扩展 无论是在linux 还是在Unix环境 中,make都是一个非常重要的编译命令.不 ...
- CSUOJ 1651 Weirdo
1651: Weirdo Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 40 Solved: 21[Submit][Status][Web Board ...
- java之 ------ 几种常见的简单设计模式
前言: 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.用于解决特定环境下.反复出现的特定问题的解决方式.使用设计模式是为了可重用代码.让代 ...
- 62.nodejs中的ejs模板学习
转自:https://blog.csdn.net/dongmelon/article/details/72403913 02.ejs.这是被include的文件 <script> cons ...
- html ---- a 标签 在新窗口打开的问题
- 4.cocos场景和层的调用
调用关系: AppDeligate.cpp bool AppDelegate::applicationDidFinishLaunching() { // initialize director aut ...
- POJ 3170 线段树优化DP
题意: 思路: 先搞一个vector 存以T2结尾的结构体 (结构体里面有开始工作的时间和花费) f[i]表示取区间[M,i)的代价 易得f[i]=min(f[k]+w,f[i]);T1<=k ...
- finally不管有没有错都会运行 finally 块用于清除 try 块中分配的任何资源,以及运行任何即使在发生异常时也必须执行的代码
finally 块用于清除 try 块中分配的任何资源,以及运行任何即使在发生异常时也必须执行的代码