第五次双周赛

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int x = 5 * (100 - 32) / 9;
	printf("fahr = 100, celsius = %d", x);

}

 

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
string m="10X98765432";
string q = "79058421637905842";
int numpd(string a) {
	for (int e = 0; e < a.size()-1; e++) {
		if (a[e] < '0' || a[e]>'9') {
			return 0;
		}
	}
	return 1;
}
int hlpd(string a) {
	int he = 0;
	for (int e = 0; e < a.size() - 1; e++) {
		int zs = q[e] - '0';
		if (zs == 0) {
			zs = 10;
		}
		he += (a[e] - '0') * zs;
	}
	he %= 11;
	if (a[a.size() - 1] != m[he]) {
		return 0;
	}
	else {
		return 1;
	}
}
signed main() {
	int n;
	cin >> n;
	int jilu = 0;
	while (n--) {
		string a;
		cin >> a;
		if (numpd(a)) {

		}
		else {
			jilu++;
			cout << a << endl;
			continue;
		}
		if (hlpd(a)) {

		}
		else {
			jilu++;
			cout << a << endl;
		}
	}
	if (jilu) {

	}
	else {
		cout << "All passed";
	}
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ren[1000000];
signed main() {
	int n;
	cin >> n;
	while (n--) {
		int a;
		cin >> a;
		if (a == 1) {
			int b;
			cin >> b;
			continue;
		}
		while (a--) {
			int x;
			cin >> x;
			ren[x] = 1;
		}
	}
	cin >> n;
	int kongge = 0;
	int meiren = 0;
	while (n--) {
		int a;
		cin >> a;
		if (ren[a] == 0) {
			meiren++;
			ren[a] = 1;
			if (kongge == 0) {
				kongge = 1;
			}
			else {
				cout << " ";
			}
			printf("%05d", a);
		}
	}
	if (meiren == 0) {
		cout << "No one is handsome";
	}
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	string a;
	cin >>a;
	int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
	for (int e = 0; e < a.size(); e++) {
		if (a[e] == 'G'||a[e]=='g') {
			a1++;
		}
		else if (a[e] == 'P' || a[e] == 'p') {
			a2++;
		}
		else if (a[e] == 'L' || a[e] == 'l') {
			a3++;
		}
		else if (a[e] == 'T' || a[e] == 't') {
			a4++;
		}
	}
	while (a1 != 0 || a2 != 0 || a3 != 0 || a4 != 0) {
		if (a1 != 0) {
			a1--;
			cout << 'G';
		}
		if (a2 != 0) {
			a2--;
			cout << 'P';
		}
		if (a3 != 0) {
			a3--;
			cout << 'L';
		}
		if (a4 != 0) {
			a4--;
			cout << 'T';
		}
	}
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	string a;
	cin >>a;
	int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
	for (int e = 0; e < a.size(); e++) {
		if (a[e] == 'G'||a[e]=='g') {
			a1++;
		}
		else if (a[e] == 'P' || a[e] == 'p') {
			a2++;
		}
		else if (a[e] == 'L' || a[e] == 'l') {
			a3++;
		}
		else if (a[e] == 'T' || a[e] == 't') {
			a4++;
		}
	}
	while (a1 != 0 || a2 != 0 || a3 != 0 || a4 != 0) {
		if (a1 != 0) {
			a1--;
			cout << 'G';
		}
		if (a2 != 0) {
			a2--;
			cout << 'P';
		}
		if (a3 != 0) {
			a3--;
			cout << 'L';
		}
		if (a4 != 0) {
			a4--;
			cout << 'T';
		}
	}
}

 

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
double jisuan(string a, double b) {
	if (a == "F") {
		return b * 1.09;
	}
	else {
		return b / 1.09;
	}
}
signed main() {
	int a;
	cin >> a;
	while (a--) {
		string b;
		double c;
		cin >> b >> c;
		printf("%.2f\n", jisuan(b, c));
	}
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool prime(ll x)
{
	if (x == 2)return 1;
	for (ll i = 2; i * i <= x; i++)
	{
		if (x % i == 0)return 0;
	}
	return 1;
}
int main()
{
	ll n;
	cin >> n;
	ll cnt = 0;
	ll yz = 2;
	ll ans = 0;
	ll last_yz = 2;
	bool flag = 0;
	if (prime(n))
	{
		cout << 1 << endl << n;
		return 0;
	}
	else
	{
		while (1)
		{
			ll tmp_n = n;
			ll tmp_cnt = 0;
			ll tmp_yz = yz;
			ll tmp_ans = 1;
			ll tmp_sum = 1;
			for (ll i = yz; i <= yz + cnt; i++)
			{
				tmp_sum *= i;
				if (tmp_sum > n)
				{
					flag = 1;
					break;
				}
			}
			//cout << "test1" << endl;
			if (flag == 1)break;
			if (n % yz != 0)
			{
				yz++;
				continue;
			}
			while (tmp_n % tmp_yz == 0)
			{
				tmp_n /= tmp_yz;
				tmp_cnt++;
				tmp_yz++;
			}
			//cout << "test2" << endl;
			if (tmp_cnt > cnt)
			{
				cnt = tmp_cnt;
				for (ll i = tmp_yz - tmp_cnt; i < tmp_yz; i++)
				{
					tmp_ans *= i;
				}
				ans = tmp_ans;
				last_yz = tmp_yz - 1;
			}
			else if (tmp_cnt == cnt)
			{
				for (ll i = tmp_yz - tmp_cnt; i < tmp_yz; i++)
				{
					tmp_ans *= i;
				}
				if (tmp_ans < ans)
				{
					ans = tmp_ans;
					last_yz = tmp_yz - 1;
				}
			}
			yz++;
		}
	}
	cout << cnt << endl;
	for (ll i = last_yz - cnt + 1; i <= last_yz; i++)
	{
		cout << i;
		if (i < last_yz)cout << '*';
	}
	cout << endl;
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int a;
	int b;
	cin >> a >> b;
	int jishu = 0;
	while (1) {
		jishu++;
		int a1 = a;
		//cout << a << endl;
		map<int,int>n;
		if (a < 1000) {
			n[0] = 1;
		}
		while (a1) {
			int c = a1 % 10;
			n[c] = 1;
			a1/= 10;
		}
		if (n.size() == b) {
			printf("%d %04d",jishu-1,a);
			break;
		}
		a++;
	}
}

 

#include<bits/stdc++.h>
using namespace std;
struct edge {
	int u, v;
}e[5005];
int fa[505];
int find(int x)
{
	while (fa[x] != x)x = fa[x];
	return x;
}
void merge(int i, int j)
{
	if (find(i) != find(j))
	{
		fa[find(i)] = find(j);
	}
}
int n, m;
int cnt1, cnt2;
int vis[505];
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)fa[i] = i;
	for (int i = 1; i <= m; i++)
	{
		cin >> e[i].u >> e[i].v;
		merge(e[i].u, e[i].v);
	}
	for (int i = 0; i < n; i++)
	{
		if (fa[i] == i)cnt1++;
	}
	//cout << "预处理:" << endl;
	//for (int i = 0; i < n; i++)
	//{
	//	cout << fa[i] << " ";
	//}
	//cout << endl;
	//cout << "cnt1 = " << cnt1 << endl;
	int k;
	cin >> k;
	for (int o = 1; o <= k; o++)
	{
		cnt2 = 0;
		int num;
		cin >> num;
		vis[num] = 1;
		for (int i = 0; i < n; i++)fa[i] = i;
		for (int i = 1; i <= m; i++)
		{
			if (vis[e[i].u] == 1 || vis[e[i].v] == 1)continue;
			merge(e[i].u, e[i].v);
		}
		for (int i = 0; i < n; i++)
		{
			if (fa[i] == i)cnt2++;
		}
		
		if (cnt2 == cnt1 || cnt2 == cnt1 + 1)
		{
			printf("City %d is lost.\n", num);
		}
		else
		{
			printf("Red Alert: City %d is lost!\n", num);
		}
		
		cnt1 = cnt2;
	}
	if (k == n)
	{
		cout << "Game Over." << endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int gender[1005];
double qm[1005][1005];
int tmp[1005];
priority_queue<int, vector<int>, greater<int> >q1;
priority_queue<int, vector<int>, greater<int> >q2;
int vis[1005];
int trans(char x)
{
	return int(x - '0');
}
void Print(int a, int b)
{
	if (gender[a] == -1)
	{
		cout << "-";
	}
	cout << a << " ";
	if (gender[b] == -1)
	{
		cout << "-";
	}
	cout << b << endl;
}
int main()
{
	int n, m;
	cin >> n >> m;
		for (int o = 1; o <= m; o++)
		{
			int k;
			cin >> k;
			string tmp_s;
			getline(cin, tmp_s);
			bool flag = 0;
			int cnt = 1;
			int num = 0;
			bool flag2 = 0;
			for (int i = 0; i < tmp_s.size(); i++)//读入
			{
				if (tmp_s[i] == ' ')
				{
					if (flag2 == 1)
					{
						num /= 10;
						tmp[cnt] = num;
						vis[num] = 1;
						cnt++;
						if (flag == 1)
						{
							flag = 0;
							gender[num] = -1;
						}
						else
						{
							gender[num] = 1;
						}
						num = 0;
					}
					continue;
				}
				else if (tmp_s[i] == '-')
				{
					flag = 1;
					continue;
				}
				else
				{
					num += trans(tmp_s[i]);
					num *= 10;
					flag2 = 1;
					
				}
			}
			if (flag2 == 1)
			{
				num /= 10;
				tmp[cnt] = num;
				vis[num] = 1;
				cnt++;
				if (flag == 1)
				{
					gender[num] = -1;
				}
				else
				{
					gender[num] = 1;
				}
			}
		
			cnt--;

			for (int i = 1; i <= cnt; i++)
			{
				for (int j = i + 1; j <= cnt; j++)
				{
					if (gender[tmp[i]] != gender[tmp[j]])
					{
						qm[tmp[i]][tmp[j]] += 1.0 / k;
						qm[tmp[j]][tmp[i]] += 1.0 / k;
						//cout << tmp[i] << " " << tmp[j] << " " << qm[tmp[i]][tmp[j]] << endl;
					}
				}
			}
		}
	if (m == 0)getchar();
	int a=0, b=0;
	string tmp_s;
	getline(cin,tmp_s);
	bool flag1 = 0;
	bool flag2 = 0;
	int cnt1 = 0;
	int num = 0;
	for (int i = 0; i < tmp_s.size(); i++)
	{
		if (tmp_s[i] == ' ')
		{
			if (flag1 == 1)
			{
				num /= 10;
				if (flag2 == 1)
				{
					flag2 = 0;
					gender[num] = -1;
				}
				else
				{
					gender[num] = 1;
				}
				a = num;
				num = 0;
			}
			continue;
		}
		else if (tmp_s[i] == '-')
		{
			flag2 = 1;
			continue;
		}
		else
		{
			num += trans(tmp_s[i]);
			num *= 10;
			flag1 = 1;

		}
	}
	num /= 10;
	b = num;
	if (m == 0)
	{
		Print(a, b);
		return 0;
	}
	if (vis[a] == 0 && vis[b] == 0)
	{
		Print(a, b);
		return 0;
	}
	bool trigger1=0, trigger2=0;
	double Max1=0, Max2=0;

	


	for (int i = 0; i < n; i++)
	{
		if (i == a)continue;
		Max1 = max(Max1, qm[a][i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (i == b)continue;
		Max2 = max(Max2, qm[b][i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (i == a)continue;
		if (qm[a][i] == Max1)
		{
			q1.push(i);
			if (i == b)trigger1 = 1;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (i == b)continue;
		if (qm[b][i] == Max2)
		{
			q2.push(i);
			if (i == a)trigger2 = 1;
		}
	}
	if (trigger1 == 1 && trigger2 == 1)
	{
		Print(a, b);
	}
	else
	{
		while (!q1.empty())
		{
			Print(a, q1.top());
			q1.pop();
		}
		while (!q2.empty())
		{
			Print(b, q2.top());
			q2.pop();
		}
	}
}

 

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
const ll mx=1e5+5;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
int n,m,k;
vector <int> ans;//存储成品信息
void show()
{//输出成品信息
    for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i];
        if(i!=ans.size()-1)
        {cout<<' ';}
    }
    cout<<'\n';
    ans.clear();
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>k;
    stack <int> t;
    queue <int> p;
    int a;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        p.push(a);
    }
    int flag=0;
    while(!p.empty())
    {
        if(ans.empty())
        {//是新松枝
            if(t.empty())
            {//盒子为空,从推送器上取
                ans.push_back(p.front());
                p.pop();
            }
            else
            {//从盒子上取
                ans.push_back(t.top());
                t.pop();
            }
            continue;
        }
        else
        {//不是新松枝
            if(ans.size()==k)
            {//已经插满,输出
                show();
                continue;
            }
            int tp=ans.size()-1;
            if(!t.empty()&&t.top()<=ans[tp])
            {//盒子不为空,则取顶部与松枝最后一片叶比较
                ans.push_back(t.top());
                t.pop();
                continue;
            }
            else if(p.front()<=ans[tp])
            {//盒子顶部不满足,看推送器
                ans.push_back(p.front());
                p.pop();
                continue;
            }
            else
            {//都不满足
                if(t.size()==m)
                {//盒子满了就开始下一个
                    show();
                    continue;
                }
                else
                {//否则将推送器的取出放到盒子
                    t.push(p.front());
                    p.pop();
                    continue;
                }
            }
        }
    }
    if(!ans.empty())
    {//推送器空了,但盒子没空
        while(!t.empty())
        {
            if(ans.size()==k)
            {//松枝满则输出
                show();
                continue;
            }
            else
            {
                if(ans.empty())
                {//新松枝
                    ans.push_back(t.top());
                    t.pop();
                    continue;
                }
                int tp=ans.size()-1;
                if(t.top()<=ans[tp])
                {//取顶部比较
                    ans.push_back(t.top());
                    t.pop();
                    continue;
                }
                else
                {//不满足则开始下一个
                    show();
                    continue;
                }
                
            }
        }
    }
    if(!ans.empty())
    {show();}//清空vector
}

 

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<vector<int>>tu;
map<int, int>dang;
signed main() {
	int N, M;
	cin >> N >> M;
	vector<int>zanshi;
	zanshi.push_back(0);
	tu.push_back(zanshi);
	while (N--) {
		zanshi.clear();
		zanshi.push_back(0);
		int a;
		cin >> a;
		for (int e = 0; e < a; e++) {
			int b;
			cin >> b;
			zanshi.push_back(b);
		}
		tu.push_back(zanshi);
	}
	//cout << tu.size()<< endl;
	//for (int e = 0; e <tu.size(); e++) {
	//	for (int i = 0; i <tu[e].size(); i++) {
	//		//cout << i << endl;
	//		cout << tu[e][i] << " ";
	//	}cout << endl;
	//}
	int jvq = 1;
	while (M--) {
		int a, b;
		cin >> a >> b;
		if (a == 0) {
			jvq = tu[jvq][b];
		}
		else if (a == 1) {
			dang[b] = jvq;
			cout << jvq << endl;
		}
		else {
			jvq = dang[b];
		}
	}
	cout << jvq;
}

猜你喜欢

转载自blog.csdn.net/sign_river/article/details/130329385