P15131 [ROIR 2026] 长方体的染色 题解
duminghao123 · · 题解
P15131 [ROIR 2026] 长方体的染色 题解
思路
其实就是分类讨论是否长为
设三边长度分别为
- 对于
a=b=c=1 时: -
-
- 其他情况,输出
0 。
-
- 对于
a > 1 且b=c=1 时: -
-
-
- 其他情况,输出
0 。
-
- 对于
a \ge b>1 且c=1 时: -
-
-
-
- 其他情况,输出
0 。
-
- 对于
a \ge b \ge c >1 时: -
-
-
-
-
- 其他情况,输出
0 。代码
#include<bits/stdc++.h> #define int long long using namespace std; int a[5],k; bool cmp(int x,int y){ return x>y; } signed main(){ cin>>a[1]>>a[2]>>a[3]>>k; sort(a+1,a+4,cmp); // cout<<a[1]<<a[2]<<a[3]; if(a[3]==1){ if(a[2]==1){ if(a[1]==1){ if(k==6) cout<<1; else cout<<0; } else{ if(k==6||k<4) cout<<0; else if(k==5) cout<<2; else cout<<a[1]-2; } } else{ if(k>4||k==1) cout<<0; else if(k==4) cout<<4; else if(k==3) cout<<(a[1]+a[2]-4)*2; else cout<<(a[1]-2)*(a[2]-2); } } else{ if(k>3) cout<<0; else if(k==3) cout<<8; else if(k==2) cout<<(a[1]+a[2]+a[3]-6)*4; else if(k==1) cout<<((a[1]-2)*(a[2]-2)+(a[1]-2)*(a[3]-2)+(a[2]-2)*(a[3]-2))*2; else cout<<(a[1]-2)*(a[2]-2)*(a[3]-2); } }
-