跳到正文

个人记录

壶关法则

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

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 5 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
namespace zorr{
	#ifdef getchar_unlocked
	#define gc getchar_unlocked
	#define pc putchar_unlocked
	#else
	#define gc getchar
	#define pc putchar
	#endif
	#define FORG(h,e,i,u) for(int i=h[u];i;i=e[i].nxt)
	#define rep(i,l,r,k) for(int i=l;i<=r;i+=k)
	#define rrep(i,l,r,k) for(int i=r;i>=l;i-=k)
    #define clr(a,val) memset(a,val,sizeof a)
    #define cpy(a,b) memcpy(a,b,sizeof a)
    #define pb emplace_back
    #define mkp make_pair
	const int inf=0x3f3f3f3f;
	const long long infll=0x3f3f3f3f3f3f3f3fll;
	const __int128 infi128=(__int128(1)<<126);
	mt19937 __rnd(time(0));
	__int128 read()
	{
		char ch=gc();int x=0;
		bool w=0;
		for(;!isdigit(ch);ch=gc())w|=(ch=='-');
		for(;isdigit(ch);ch=gc())x=(x<<3)+(x<<1)+(ch^48);
		return w?-x:x;
	}
	void write(__int128 x)
	{
		if(x<0)pc('-'),x=-x;
		if(x>9)write(x/10);
		pc(x%10+48);
	}
	void file(string in,string out)
	{
		freopen(in.c_str(),"r",stdin);
		freopen(out.c_str(),"w",stdout);
	}
	int rnd(int l,int r)
	{
		int x=abs((int)(__rnd()));
		return x%(r-l+1)+l;
	}
	int qpow(int x,int y,int mod)
	{
		int res=1;
		while(y)
		{
			if(y&1)
				res=res*x%mod;
			x=x*x%mod;
			y>>=1;
		}
		return res;
	}
}
using namespace zorr;
void solve()
{
    int rod,balloon;
    double P=0;
    bool classmate;
    string level;
    cin>>rod>>balloon>>classmate>>level;
    if(classmate)
    {
        P=1;
        cout<<"hu guan";
        return ;
    }
    if(level=="Grey")
    {
        if(rod>=8||balloon>=6)P=1;
        else if(rod>=6||balloon>=4)P=0.8;
        else P=0;
    }
    if(level=="Blue")
    {
        if(rod>=4||balloon)P=0.1;
        else P=0.01;
    }
    if(level=="Green")
    {
        if(rod>=6||balloon>=4)P=0.3;
        else if(rod>=4||balloon)P=0.2;
        else P=0.1;
    }
    if(level=="Orange")
    {
        if(rod>=8||balloon>=6)P=1;
        else if(rod>=6||balloon>=4)P=0.85;
        else if(rod>=3||balloon)P=0.35;
        else P=0.2;
    }
    if(level=="Red")
    {
        if(rod>=8||balloon>=6)P=1;
        else if(rod>=6||balloon>=4)P=0.95;
        else if(rod>=3||balloon)P=0.78;
        else P=0.5;
    }
    if(level=="Purple")
    {
        P=1;
        cout<<"hu guan";
        return ;
    }
    if(rnd(1,10000)<=P*10000)cout<<"hu guan";
    else cout<<"bu hu guan";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int T=1;
	//cin>>T;
	//T=read();
	rep(i,1,T,1)solve();
}
原文