BNUZ_2019_IT节_ACM_网络赛 题解

队友写的题解(无代码)

A.分不分

#include
#define ll long long
using namespace std;

int main(){
	int T,cas = 1,x;
	cin>>T;
	while(T--){
		cin>>x;
		printf("Case #%d:\n",cas++);
		if(x%2==1){
			cout<

B.橘猫与千层糕

#include 

#define MAXN 6
#define MAXM 200005
#define MOD 1000000007
#define ll long long

using namespace std;

ll dp[200005][6];
ll fuc[6][20];
ll bp[6];

ll getNum(ll x, ll y) {
	if (y != 0 && x % 5 >= y) {
		return x / 5 + 1;
	}
	return x / 5;
}

int main() {
	int T, cas = 1;
	ll a, b, n;
	scanf("%d", &T);
	while (T--) {
		memset(dp, 0, sizeof(dp));
		scanf("%lld %lld %lld", &n, &a, &b);
		for (ll i = 0; i <= 4; i++) {
			bp[i] = getNum(b, i) - getNum(a - 1, i);
		}
		dp[0][0] = 1;
		ll tx = 1;
		for (ll i = 1; i <= n; i++) {
			for (ll j = 0; j < 5; j++) {
				for (ll k = 0; k < 5; k++) {
					dp[i][j] = (dp[i][j] + (dp[i - 1][(j - k + 5) % 5] * bp[k]) % MOD) % MOD;
				}
			}
			tx = (tx * i) % MOD;
		}
		printf("Case #%d:\n", cas++);
		printf("%lld\n", (dp[n][0]) % MOD);
	}
}

C.橘猫吃千层糕

#include
#define ll long long
using namespace std;

ll a[1000000];

int main(){
	int ans = 1,n;
	while(cin>>n){
		for(int i = 0 ; i < n ; i++){
			cin>>a[i];
		}
		sort(a, a+n);
		printf("Case #%d:\n",ans++);
		if(n % 2 == 0){
			printf("%.2lf\n", 1.0 * (a[n/2-1] + a[n/2]) / 2);
		}else{
			printf("%.2lf\n", 1.0 * (a[n/2]));
		}
	}
}

D.Erwin Schrödinger的橘猫

#include

using namespace std;

//对于字符串比较多的要统计个数的,map被卡的情况下,直接用字典树
//很多题都是要用到节点下标来表示某个字符串
const int maxn =2e6+5;//如果是64MB可以开到2e6+5,尽量开大
int tree[maxn][30];//tree[i][j]表示节点i的第j个儿子的节点编号
bool flagg[maxn];//表示以该节点结尾是一个单词
int tot;//总节点数
void insert_(char *str) {
	int  len=strlen(str);
	int root=0;
	for(int i=0; i>n;
	for(int i = 0 ; i < n ; i++) {
		cin>>s;
		insert_(s);
	}
	cin>>m;
	for(int i = 0 ; i < m ; i++) {
		cin>>s;
		printf("Case #%d:\n",T++);
		if(find_(s)) {
			cout<<"YES"<

 

你可能感兴趣的:(ACM题目和算法)