首页 > 其他 > 详细

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

时间:2017-05-22 11:28:12      阅读:309      评论:0      收藏:0      [点我收藏+]

题目链接: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

 

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

原文:http://www.cnblogs.com/geloutingyu/p/6888450.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!