计蒜课/百度的年会游戏(枚举)

题目链接:https://nanti.jisuanke.com/t/15503

 

题意:中文题诶~

 

思路:一开始想写的直接模拟gg了,赛后才想到这里可以直接枚举两个色子的点数,再来判断一下当前情况是否可行就好了...

 

代码:

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int a[5], x, y;
 5 
 6 void yxl(int& fx, int& cnt){
 7     while(a[cnt] < fx){
 8         fx -= a[cnt];
 9         cnt--;
10         if(!cnt) cnt = 4;
11     }
12 }
13 
14 bool is_ok(int fx, int fy){
15     int cnt = fx+fy;
16     cnt %= 4;
17     if(!cnt) cnt = 4;
18     fx += 1;
19     yxl(fx, cnt);
20     if(cnt==x && y==fx) return true;
21     fx += 8;
22     yxl(fx, cnt);
23     if(cnt==x && y==fx) return true;
24     fx += 8;
25     yxl(fx, cnt);
26     if(cnt==x && y==fx) return true;
27     return false;
28 }
29 
30 int main(void){
31     int ans=0;
32     cin >> a[1] >> a[2] >> a[3] >> a[4] >> x >> y;
33     for(int i=1; i<=6; i++){
34         for(int j=i; j<=6; j++){
35             if(is_ok(i, j)) ans++;
36         }
37     }
38     cout << ans << endl;
39     return 0;
40 }
View Code

 

转载于:https://www.cnblogs.com/geloutingyu/p/6888450.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值