acmer10 题解分享 · 2024/4/3
六角填数(结果填空) - 题解
``` #include<iostream> #include<cstring> #include<algorithm> using namespace std; int a[9]={2,4,5,6,7,9,10,11,12}; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); do{ int x1=a[0]+1+a[3]+a[5]; int x2=1+a[1]+a[4]+a[8]; int x3=8+a[0]+a[1]+a[2]; int x4=a[5]+a[6]+a[7]+a[8]; int x5=11+a[3]+a[6]; int x6=a[2]+a[4]+a[7]+3; if(x1==x2&&x2==x3&&x3==x4&&x4==x5&&x5==x6) { cout<<a[3]<<endl; return 0; } }while(next_permutation(a,a+9)); return 0; } ```
查看全文
0 0 1 2
LIUZHANSHUO 题解分享 · 2024/4/9
六角填数(结果填空) - 题解
include int​main(){ ​int​a,b,c,d,e,q,w,z,x; ​for​(a=2;a<=12;a++){ ​if​(a!=8&&a!=3){ ​for​(b=2;b<=12;b++){ ​if​(b!=8&&b!=3&&b!=a){ ​for​(c=2;c<=12;c++){ ​if​(c!=8&&c!=3&&c!=b&&c!=a){ ​for​(d=2;d<=12;d++){ ​if​(d!=8&&d!=3&&d!=b&&d!=a&&d!=c){ ​for​(e=2;e<=12;e++){ ​if​(e!=8&&e!=3&&e!=b&&e!=a&&e!=c&&e!=d){ ​for​(q=2;q<=12;q++){ ​if​(q!=8&&q!=3&&q!=b&&q!=a&&q!=c&&q!=d&&q!=e){ ​for​(w=2;w<=12;w++){ ​if​(w!=8&&w!=3&&w!=b&&w!=a&&w!=c&&w!=d&&w!=e&&w!=q){ ​for​(z=2;z<=12;z++){ ​if​(z!=8&&z!=3&&z!=b&&z!=a&&z!=c&&z!=d&&z!=e&&z!=q&&z!=w){ ​for​(x=2;x<=12;x++){ ​if​(x!=8&&x!=3&&x!=b&&x!=a&&x!=c&&x!=d&&x!=e&&x!=q&&x!=w&&x!=z){ ​int​o=8+a+b+c; ​int​y=1+a+d+q; ​int​h=1+b+e+x; ​int​v=8+d+w+3; ​int​p=c+e+z+3; ​int​g=q+w+z+x; ​if​(o==y&&o==h&&o==v&&o==p&&o==g) ​{ ​printf​(​"%d"​,d); ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​} ​return​0; }
查看全文
0 0 0 4