跳到正文

个人记录

2026.10.20 学习总结

cgy20140502约 5 分钟
原文
文章信息与版本

文章信息

发布
2026年10月20日
收录
2026年10月21日
更新
2026年11月5日
篇幅
约 5 分钟

版本

  1. v1当前

考试内容

HNCPC 模拟赛。

https://qoj.ac/contest/2668

会的题目

A

首先分解质因数,可以知道,要分解成 5x(x≤n÷5x)5^x (x \le n \div 5^x) 次方形式,然后输出 xx 个 AI,剩下的多余的输出 A 占位即可。

code
C++
#include <bits/stdc++.h>
using namespace std;
int n,cnt;
string s;
int main(){
	cin >> n;
	while (n % 5 == 0 && n/5 >= (cnt+1)*2){
		cnt++;
		n /= 5;
	}
	for (int i = 1;i <= cnt;++i) s += "AI";
	for (int i = 1;i <= n-cnt*2;++i) s += 'A';
	cout << s;
	return 0;
}

H

给定了开始时间和结束时间,直接算出总耗时,然后减去消耗的时间。

code
C++
#include <bits/stdc++.h>
using namespace std;
int n,a[105],ans;
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); 
	cin >> n;
	for (int i = 1;i <= n;i++) cin >> a[i],ans += a[i];
	cout << 600-ans;
	return 0;
}

I

打表+暴力安排就做完了。

code
C++
#include <bits/stdc++.h>
using namespace std;
unordered_map <string,int> mp;
string s,a[30][30];
string t[] = {"","UW","UJ","UWR","MAP","PW","AGH","PG","NLU","PUT","PO","PWR",
"SGGW","UMCS","UR","ZUT","DTP","GOO","HUA","KUL","PL","PM","PS","UAM","UG","UMK","UO","WAT"};
const int ex[] = {0,0,0,-1,-1,-1,1,1,1};
const int ey[] = {0,1,-1,0,-1,1,0,-1,1};
int main(){
	mp["UW"] = 11;
	mp["UJ"] = 9;
	mp["UWR"] = 8;
	mp["MAP"] = 7;
	mp["PW"] = 6;
	mp["AGH"] = 5;
	mp["PG"] = 4;
	mp["NLU"] = 3;
	mp["PUT"] = 3;
	mp["PO"] = 2;
	mp["PWR"] = 2;
	mp["SGGW"] = 2;
	mp["UMCS"] = 2;
	mp["UR"] = 2;
	mp["ZUT"] = 2;
	mp["DTP"] = 1;
	mp["GOO"] = 1;
	mp["HUA"] = 1;
	mp["KUL"] = 1;
	mp["PL"] = 1;
	mp["PM"] = 1;
	mp["PS"] = 1;
	mp["UAM"] = 1;
	mp["UG"] = 1;
	mp["UMK"] = 1;
	mp["UO"] = 1;
	mp["WAT"] = 1;
	cin >> s;
	a[1][1] = s;
	mp[s] -- ;
	for(int i = 1 ; i <= 8 ; i ++)
	{
		for(int j = 1 ; j <= 10 ; j ++)
		{
			if(i == 1 && j == 1) continue ;
			for(int k = 1;k <= 27;k++)
			{
				if(mp[t[k]] == 0) continue;
				bool flag = 0;
				for(int l = 1;l <= 8;l++) if(a[i + ex[l]][j + ey[l]] == t[k]) {flag = 1;break;}
				if(flag == 1) continue;
				else {a[i][j] = t[k],mp[t[k]]--;break;}
			}
		}
	}
	for (int i = 1;i <= 8;i++){
		for (int j = 1;j <= 10;j++)
			cout << a[i][j] << " ";
		cout << "\n";
	}
	return 0;
}

K

题意就是求最大值减去次大值,直接排序即可。

code
C++
#include <bits/stdc++.h>
using namespace std;
int n,a[300005];
int main(){
	cin >> n;
	for (int i = 1;i <= n;i++) cin >> a[i];
	sort(a+1,a+n+1);
	cout << a[n]-a[n-1];
	return 0;
}
原文