2019ccpc女生赛 9/11

在2019年的CCPC女生赛中,由于未能充分准备,作者在比赛中遇到了一些问题。文章详细回顾了比赛中的A到K共11道题目,分析了自己的错误,如I题的误解和E题复杂度的错误估计。在A、B题中,虽然实际解法是平方根级复杂度,但通过枚举约数同样能达到效果。C题采用了一种巧妙的分配策略。D题使用了树剖解决,E题通过维护子树颜色的映射简化了计算。F题通过动态规划解决,G、H、I、J、K题分别涉及了不同的解题思路。尽管遇到挫折,但这次比赛提供了宝贵的教训和经验。
摘要由CSDN通过智能技术生成

闲暇之余并没有好好补题而和小南瓜一起开了一场女生赛x
然而自己菜死了,没看清I的题目,还分析错了E的复杂度,导致最后只有9题

A

/* ***********************************************
Author        :BPM136
Created Time  :2019/8/2 13:31:09
File Name     :A.cpp
************************************************ */

#include <bits/stdc++.h>
#include <sys/timeb.h>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define filein(x) freopen(#x".in","r",stdin)
#define fileout(x) freopen(#x".out","w",stdout)
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
#define mkdfile() freopen("in.txt","w",stdout);
#define setlargestack(x) int _SIZE=x<<20;char *_PPP=(char*)malloc(_SIZE)+_SIZE;__asm__("movl %0, %%esp\n" :: "r"(_PPP));
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define readg(_x1,_y1,_x2,_y2) read(_x1),read(_y1),read(_x2),read(_y2)
#define USE_CIN_COUT ios::sync_with_stdio(0)

using namespace std;

int random(int l, int r) {
   
	static std::random_device rd;
	struct timeb timeSeed;
	ftime(&timeSeed);
	size_t seed = timeSeed.time * 1000 + timeSeed.millitm;  // milli time
	static std::mt19937 gen(seed);
	std::uniform_int_distribution<> u(l, r);
	return u(gen);
}

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int  ui;
typedef unsigned long long ull;
typedef pair<int, int> pii;

namespace fastIO{
     
    #define BUF_SIZE 100000  
    #define OUT_SIZE 100000  
    //fread->read  
    bool IOerror=0;  
    inline char nc(){
     
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;  
		if (p1==pend){
     
			p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);  
			if (pend==p1){
   IOerror=1;return -1;}  
			//{printf("IO error!\n");system("pause");for (;;);exit(0);}  
		}  
		return *p1++;  
	}  
	inline bool blank(char ch){
   return ch==32||ch==10||ch==13||ch==9;}  
	inline bool enter(char ch){
   return ch==10||ch==13;}
	inline void read(int &x){
     
		bool sign=0; char ch=nc(); x=0;  
		for (;blank(ch);ch=nc());  
		if (IOerror)return;  
		if (ch==45)sign=1,ch=nc();  
		for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
		if (sign)x=-x;  
	}  
	inline void read(ll &x){
     
		bool sign=0; char ch=nc(); x=0;  
		for (;blank(ch);ch=nc());  
		if (IOerror)return;  
		if (ch==45)sign=1,ch=nc();  
		for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
		if (sign)x=-x;  
	}  
	inline void read(double &x){
     
		bool sign=0; char ch=nc(); x=0;  
		for (;blank(ch);ch=nc());  
		if (IOerror)return;  
		if (ch==45)sign=1,ch=nc();  
		for (;ch>=48&&ch<=57;ch=nc())x=x*10+ch-48;  
		if (ch==46){
     
			double tmp=1; ch=nc();  
			for (;ch>=48&&ch<=57;ch=nc())tmp/=10.0,x+=tmp*(ch-48);  
		}  
		if (sign)x=-x;  
	}  
	inline void read(char *s){
     
		char ch=nc();  
		for (;blank(ch);ch=nc());  
		if (IOerror)return;  
		for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch;  
		*s=0;  
	}  
	inline void readln(char *s) {
   
		char ch=nc();
		for (;blank(ch);ch=nc());
		if(IOerror)return;
		for(;!enter(ch)&&!IOerror;ch=nc())*s++=ch;
		*s=0;
	}
	inline void read(char &c){
     
		for (c=nc();blank(c);c=nc());  
		if (IOerror){
   c=-1;return;}  
	} 
#undef OUT_SIZE  
#undef BUF_SIZE  
}
using fastIO::read;

int main() {
   
	int n;
	scanf("%d",&n);
	double sum = 0;
	for(int i = 0;i < n;i++) {
   
		int x;
		scanf("%d",&x);
		if(sum >= 100 && sum < 150) x *= 0.8;
		else if(sum >= 150 && sum < 400) x *= 0.5;
		sum += x;
	}
	printf("%.2f\n",sum);
	return 0;
}

B

其实可以根号n的复杂度,但是实际上直接算sum然后枚举约数也是根号n复杂度(可以思考下为什么

/* ***********************************************
Author        :BPM136
Created Time  :2019/8/2 13:53:50
File Name     :B.cpp
************************************************ */

#include <bits/stdc++.h>
#include <sys/timeb.h>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define USE_CIN_COUT ios::sync_with_stdio(0)
#define filein(x) freopen(#x".in","r",stdin)
#define fileout(x) freopen(#x".out","w",stdout)
#define file(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout);
#define mkd(x) freopen(#x".in","w",stdout);

using namespace std;

int random(int l, int r) {
   
	static std::random_device rd;
	struct timeb timeSeed;
	ftime(&timeSeed);
	size_t seed = timeSeed.time * 1000 + timeSeed.millitm;  // milli time
	static std::mt19937 gen(seed);
	std::uniform_int_distribution<> u(l, r);
	return u(gen);
}

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main() {
   
	ll n;
	cin >> n;
	ll sum = (n + 1) * n / 2;
	for (ll i = 2; i * i <= sum; ++i) 
		if (sum % i == 0) {
   
			cout << sum / i << '\n';
			return 0;
		}
    return 0;
}

C

考虑最开始就分配好每个都是1,然后不足的部分慢慢+1挪过去,因为开口朝上的二次函数的delta y是递增的,所以是对的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值