题意:n个骰子按顺序立成一个栈,求正面向你的那一面的和的最大值。

题解:由于规定了顺序,这题也就毫无技术可言了,直接6的枚举第一个骰子的top面其余就确定了。

View Code
 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 using namespace std;
 5 int getmax(int a,int b)
 6 {
 7     for(int i=6;i>=4;i--)
 8         if(i!=a&&i!=b)
 9             return i;
10 }
11 int po[10005][7];
12 int main()
13 {
14     int T;
15     for(scanf("%d",&T);T;T--)
16     {
17         int n,ans=0;
18         scanf("%d",&n);
19         for(int i=0;i<n;i++)
20         {
21             int a,b,c,d,e,f;
22             scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
23             po[i][a]=f;po[i][f]=a;
24             po[i][b]=d;po[i][d]=b;
25             po[i][c]=e;po[i][e]=c;
26         }
27         int sum,lx;
28         for(int i=1;i<=6;i++)
29         {
30             sum=getmax(i,lx=po[0][i]);
31             for(int j=1;j<n;j++)
32             {
33                 sum+=getmax(lx,po[j][lx]);
34                 lx=po[j][lx];
35             }
36             ans=max(sum,ans);
37         }
38         printf("%d\n",ans);
39     }
40     return 0;
41 }

相关文章:

  • 2021-11-27
  • 2021-08-11
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2022-01-30
猜你喜欢
  • 2021-10-27
  • 2022-12-23
  • 2021-06-21
  • 2021-12-12
  • 2021-10-01
  • 2021-10-04
  • 2021-09-30
相关资源
相似解决方案