Andrew Stankevich Contest 45 (ASC 45)

经典队内倒二啊 十分经典 感觉有蛮久没训练了 一打起来十分拉跨
Problem A CFGym 100520A Analogous Sets +++
Problem B CFGym 100520B Bayes' Law ???
Problem C CFGym 100520C Catalian Sequences ???
Problem D CFGym 100520D Drunkard's Walk !!!
正解的想法我们想过的 不知道为啥把它hack了 丢
构造一棵满二叉树然后分配叶子结点就行
其中 p个指向home q-p个指向bar 剩余的指向1号结点
这样的话流量最终都只会流向那q个结点

#include<bits/stdc++.h>
using namespace std;
const int N = 300;
int s[15],p2[15];
#define LOCAL
int main(){
	#ifdef LOCAL
	freopen("drunkard.in", "r", stdin);
	freopen("drunkard.out", "w", stdout);
	#endif
	int p,q;
	p2[0] = 1;
	s[0] = 1;
	for(int i = 1; i <= 10; i++){
		p2[i] = p2[i-1]*2;
		s[i] = s[i-1] + p2[i]; 
	}
	while(~scanf("%d%d",&p,&q)){
		if(p==0&&q==0) break;
		int j;
		for(int i = 1; i <= 10; i++){
			if(q <= p2[i]){
				j = i;
				break;
			}
		}
		int n = s[j] + 2;
		printf("%d\n",n);
		for(int i = 1; i <= n-2-p2[j]; i++){
			printf("%d %d\n",i*2,i*2+1);
		}
		int now = n-2-p2[j]+1;
		for(int i = now; i <= now+p-1; i++){
			printf("%d %d\n",n-1,n-1);
		}
		now+=p;
		for(int i = now; i <= now+q-p-1; i++){
			printf("%d %d\n",n,n);
		}
		now+=q-p;
		for(int i = now; i <= n-2; i++){
			printf("%d %d\n",1,1);
		}
	}
	return 0;
}

Problem E CFGym 100520E Elegant Scheduling ???
Problem F CFGym 100520F Flights !!!
Problem G CFGym 100520G Genome of English Literature ???
Problem H CFGym 100520H Hide-and-Seek ???
Problem I CFGym 100520I Informatics Final Project ???
Problem J CFGym 100520J Japanese Origami ???
Problem K CFGym 100520K Kabbalah for Two !!!

上一篇:搬砖 - js 排序es6


下一篇:C++ 字符串字符转为16进制