#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
string ch[4][2]={{"L","Y"},{"A","G"},{"L","M"},{"A","Gay"}};
int main(){
srand(time(0));
cout<<"GENERATE → Card spread generated\n";
cout<<endl;
int T;
cin>>T;
while(T--){
string str;
cin>>str;
if(str!="GENERATE"){
cout<<"You are gay!\n";
continue;
}
int t=rand()%24;
int s=rand()%16;
int a[4]={1,2,3,4};
int b[4]={0,0,0,0};
while(t--){
next_permutation(a,a+4);
}
int now=0;
while(s){
b[now]=s%2;
s/=2;
now++;
}
string st;
int pts=0;
for(int i=0;i<4;++i){
st+=ch[a[i]-1][b[i]];
cout<<ch[a[i]-1][b[i]]<<' ';
}
cout<<endl<<endl;
for(int i=0;i<st.size()-1;++i){
if(st[i]=='L'&&st[i+1]=='A'){
cout<<"Common +1\n";
cout<<endl;
cout<<"LA\n";
cout<<endl;
pts+=1;
}
}
if(st.find("MY")!=-1){
cout<<"Common +1\n";
cout<<endl;
cout<<"MY\n";
cout<<endl;
pts+=1;
}
if(st.find("Gay")!=-1){
cout<<"Common +1\n";
cout<<endl;
cout<<"Gay\n";
cout<<endl;
pts+=1;
}
if(st.find("GYM")!=-1){
cout<<"Uncommon +2\n";
cout<<endl;
cout<<"GYM\n";
cout<<endl;
pts+=2;
}
if(st.find("LGM")!=-1){
cout<<"Uncommon +2\n";
cout<<endl;
cout<<"LGM\n";
cout<<endl;
pts+=2;
}
if(st.find("GAY")!=-1){
cout<<"Rare +3\n";
cout<<endl;
cout<<"GAY\n";
cout<<endl;
pts+=3;
}
if(st.find("YAG")!=-1){
cout<<"Rare +3\n";
cout<<endl;
cout<<"YAG\n";
cout<<endl;
pts+=3;
}
if(st.find("LALA")!=-1){
cout<<"Epic +4\n";
cout<<endl;
cout<<"LALA\n";
cout<<endl;
pts+=4;
}
if(st.find("GayGAY")!=-1){
cout<<"Epic +4\n";
cout<<endl;
cout<<"GayGAY\n";
cout<<endl;
pts+=4;
}
if(st.find("GAYGay")!=-1){
cout<<"Epic +4\n";
cout<<endl;
cout<<"GAYGay\n";
cout<<endl;
pts+=4;
}
if(st.find("GayYAG")!=-1){
cout<<"Epic +4\n";
cout<<endl;
cout<<"GayYAG\n";
cout<<endl;
pts+=4;
}
if(st.find("YAGGay")!=-1){
cout<<"Epic +4\n";
cout<<endl;
cout<<"YAGGay\n";
cout<<endl;
pts+=4;
}
if(st.find("LGMGay")!=-1){
cout<<"Anomaly +6\n";
cout<<endl;
cout<<"LGMGay\n";
cout<<endl;
pts+=6;
}
if(st.find("GayLGM")!=-1){
cout<<"Anomaly +6\n";
cout<<endl;
cout<<"GayLGM\n";
cout<<endl;
pts+=6;
}
if(st.find("LAGayM")!=-1){
cout<<"Mythic +8\n";
cout<<endl;
cout<<"LAGayM\n";
cout<<endl;
pts+=8;
}
cout<<"Final Points : "<<pts<<endl;
cout<<endl;
if(pts==0) cout<<"Trash\n";
else if(pts==1) cout<<"Common\n";
else if(pts==2) cout<<"Uncommon\n";
else if(3<=pts&&pts<=4) cout<<"Rare\n";
else if(5<=pts&&pts<=8) cout<<"Epic\n";
else if(pts==9) cout<<"Anomaly\n";
else if(pts==10) cout<<"Mythic\n";
cout<<endl;
}
}
概率
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
string ch[4][2]={{"L","Y"},{"A","G"},{"L","M"},{"A","Gay"}};
int cnt[7];
int main(){
srand(time(0));
cout<<"GENERATE → Card spread generated\n";
cout<<endl;
int T=1000000;
// cin>>T;
while(T--){
// string str;
// cin>>str;
// if(str!="GENERATE"){
// cout<<"You are gay!\n";
// continue;
// }
int t=rand()%24;
int s=rand()%16;
int a[4]={1,2,3,4};
int b[4]={0,0,0,0};
while(t--){
next_permutation(a,a+4);
}
int now=0;
while(s){
b[now]=s%2;
s/=2;
now++;
}
string st;
int pts=0;
for(int i=0;i<4;++i){
st+=ch[a[i]-1][b[i]];
// cout<<ch[a[i]-1][b[i]]<<' ';
}
// cout<<endl<<endl;
for(int i=0;i<st.size()-1;++i){
if(st[i]=='L'&&st[i+1]=='A'){
// cout<<"Common +1\n";
// cout<<endl;
// cout<<"LA\n";
// cout<<endl;
pts+=1;
}
}
if(st.find("MY")!=-1){
// cout<<"Common +1\n";
// cout<<endl;
// cout<<"MY\n";
// cout<<endl;
pts+=1;
}
if(st.find("Gay")!=-1){
// cout<<"Common +1\n";
// cout<<endl;
// cout<<"Gay\n";
// cout<<endl;
pts+=1;
}
if(st.find("GYM")!=-1){
// cout<<"Uncommon +2\n";
// cout<<endl;
// cout<<"GYM\n";
// cout<<endl;
pts+=2;
}
if(st.find("LGM")!=-1){
// cout<<"Uncommon +2\n";
// cout<<endl;
// cout<<"LGM\n";
// cout<<endl;
pts+=2;
}
if(st.find("GAY")!=-1){
// cout<<"Rare +3\n";
// cout<<endl;
// cout<<"GAY\n";
// cout<<endl;
pts+=3;
}
if(st.find("YAG")!=-1){
// cout<<"Rare +3\n";
// cout<<endl;
// cout<<"YAG\n";
// cout<<endl;
pts+=3;
}
if(st.find("LALA")!=-1){
// cout<<"Epic +4\n";
// cout<<endl;
// cout<<"LALA\n";
// cout<<endl;
pts+=4;
}
if(st.find("GayGAY")!=-1){
// cout<<"Epic +4\n";
// cout<<endl;
// cout<<"GayGAY\n";
// cout<<endl;
pts+=4;
}
if(st.find("GAYGay")!=-1){
// cout<<"Epic +4\n";
// cout<<endl;
// cout<<"GAYGay\n";
// cout<<endl;
pts+=4;
}
if(st.find("GayYAG")!=-1){
// cout<<"Epic +4\n";
// cout<<endl;
// cout<<"GayYAG\n";
// cout<<endl;
pts+=4;
}
if(st.find("YAGGay")!=-1){
// cout<<"Epic +4\n";
// cout<<endl;
// cout<<"YAGGay\n";
// cout<<endl;
pts+=4;
}
if(st.find("LGMGay")!=-1){
// cout<<"Anomaly +6\n";
// cout<<endl;
// cout<<"LGMGay\n";
// cout<<endl;
pts+=6;
}
if(st.find("GayLGM")!=-1){
// cout<<"Anomaly +6\n";
// cout<<endl;
// cout<<"GayLGM\n";
// cout<<endl;
pts+=6;
}
if(st.find("LAGayM")!=-1){
// cout<<"Mythic +8\n";
// cout<<endl;
// cout<<"LAGayM\n";
// cout<<endl;
pts+=8;
}
// cout<<"Final Points : "<<pts<<endl;
// cout<<endl;
if(pts==0) cnt[0]++;
else if(pts==1) cnt[1]++;
else if(pts==2) cnt[2]++;
else if(3<=pts&&pts<=4) cnt[3]++;
else if(5<=pts&&pts<=8) cnt[4]++;
else if(pts==9) cnt[5]++;
else if(pts==10) cnt[6]++;
// cout<<endl;
}
for(int i=0;i<7;++i) cout<<cnt[i]*1.0/1000000.0<<' ';
}