【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 ...
随机推荐
- OpenJDK源码研究笔记(十四):三种经典的设计方法,接口,接口-抽象类-具体实现类,接口-具体实现类
在研究OpenJDK源码过程中,我发现常用的设计方法就是2种:接口,接口-抽象类-具体实现类 . 在一些其它开源框架和业务开发中,经常存在着第3种设计,接口-具体实现类. 1.只有接口,没有实现类. ...
- 研究一些复杂java开源软件代码的体会(转)
原文地址:http://herman-liu76.iteye.com/blog/2349026 有时候看源代码是非常有趣的事情,象是思考游戏,象是思考棋局... 平时做J2EE项目中, ...
- Linux系统消息队列框架Kafka单机安装配置
http://www.ithao123.cn/content-11128587.html
- C# ArcGIS Engine 线打断
/// <summary> /// 打断线,用于在点击点处,打断该条线 /// </summary> /// <param name="t_pLineFeatu ...
- [Python] Reuse Code in Multiple Projects with Python Modules
A module is a function extracted to a file. This allows you to import the function and use it in any ...
- RTSP传输协议之Methods总结
RTSP/1.0 200 OK Server: DSS/5.5.5 (Build/489.16; Platform/Linux; Release/Darwin; state/beta; ) Cseq: ...
- Web跨域问题基础
同源策略(Same origin policy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响.可以说Web是构建在同源策略基础之上的,浏览器只 ...
- Android Retrofit+RxJava 优雅的处理服务器返回异常、错误
标签: 开始本博客之前,请先阅读: Retrofit请求数据对错误以及网络异常的处理 异常&错误 实际开发经常有这种情况,比如登录请求,接口返回的 信息包括请求返回的状态:失败还是成功,错误码 ...
- C/C++(基础-运算符详解)
运算符 任何表达式是有值的 int a = 2; int b = 3; a*=b+4;//a=a*(b+4);"*"*=的优先级层次和=号的层次一样. printf("% ...
- Java生产者与消费者(下)
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 上一讲我们让消费者和生产者都各停1毫秒,实际上大多并不是这样的.第二讲,我们讲一个极端的例子和一个正 ...