nefu 大一大二cf个人赛(未完待续)

题目网址

https://vjudge.net/contest/299443#problem (复制到谷歌浏览器打开)

A题

#include <bits/stdc++.h>
using namespace std;
string a;
int k,tmp,ans;
int main()
{
    while(cin>>a)
    {
        ans=0;
        for(int i=0;i<a.length();i++)
        {
            if(a[i]=='.')
            {k=i-1;break;}
        }
        if(a[k]=='9'){printf("GOTO Vasilisa.\n");continue;}
        else
        {
            for(int i=0;i<=k-1;i++)
                printf("%c",a[i]);
            if(a[k+2]>='5')printf("%c\n",a[k]+1);
            else printf("%c\n",a[k]);
        }
    }
    return 0;
}

B题

#include <bits/stdc++.h>
using namespace std;
int n,s,a1,b1,v1,v2,ave,num1,num2,flag,a[1010];//a1是多的那个酒杯的编号
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n)
    {
        s=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            s=s+a[i];
        }
        ave=s/n;flag=0;num1=num2=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]!=ave)flag=1;
            if(a[i]>ave){num1++;a1=i;v1=a[i]-ave;}
            if(a[i]<ave){num2++;b1=i;v2=ave-a[i];}
        }
        if(flag==0)printf("Exemplary pages.\n");
        else
        {
            if(num1==1&&num2==1)
            {
                if(v1==v2) printf("%d ml. from cup #%d to cup #%d.\n",v1,b1,a1);
                else printf("Unrecoverable configuration.\n");
            }
            else printf("Unrecoverable configuration.\n");
        }
    }
    return 0;
}

C题

贴的别人的代码…

#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
string s;
queue<string> q;
map<string,int> mp;
void bfs(string s)
{
	mp[s]=true;
	q.push(s);
	while(!q.empty())
	{
		string u=q.front(),v1,v2,v3;
		q.pop();
		v1=v2=v3=u;
		v1[0]=u[3],v1[1]=u[0],v1[2]=u[1],v1[3]=u[2];	
		v2[0]=u[4],v2[5]=u[0],v2[2]=u[5],v2[4]=u[2];
		v3[5]=u[1],v3[3]=u[5],v3[4]=u[3],v3[1]=u[4];
		if(!mp[v1]) mp[v1]=true,q.push(v1);
		if(!mp[v2])	mp[v2]=true,q.push(v2);
		if(!mp[v3])	mp[v3]=true,q.push(v3); 
	}
}
int main()
{
	cin>>s;
	int res=0;
	sort(s.begin(),s.end());
	do{
		if(mp[s])	continue;
		res++;
		bfs(s);	
	}while(next_permutation(s.begin(),s.end()));
	cout<<res<<'\n';
	return 0;
}

D\E题 未完待续。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

nefu-ljw

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值