P2348 三国杀I(洗牌&发牌)

Aimee

模拟即可

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int n,m,k,p;
int a[110001];
int b[110001];
struct car{
    string cn;
    string ty;
}c[110001];
void wash(){
    for(int i=1;i<=m;i+=2){
            b[i]=a[(i/2+1)+m/2];
            b[i+1]=a[(i/2+1)];
    }
    for(int i=1;i<=m;++i){
        a[i]=b[i]; 
    }
}
int main(){
    scanf("%d%d%d%d",&n,&m,&k,&p);
    if(m<4*n){
        cout<<"Error:cards not enough";
        return 0;
    }
    for(int i=1;i<=m;++i){
        a[i]=i;
        b[i]=i;
        cin>>c[i].cn>>c[i].ty;
    }
    m=m/2*2;
    while(k--){
        wash(); 
    } 
    for(int i=1;i<=4*n;++i){
        if(i%n==p)
        cout<<c[a[i]].cn<<" "<<c[a[i]].ty<<endl;
    }
    return 0;
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇