日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

2016年第七届蓝桥杯C/C++ A组国赛 —— 第一题:随意组合

發(fā)布時(shí)間:2024/5/6 c/c++ 78 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2016年第七届蓝桥杯C/C++ A组国赛 —— 第一题:随意组合 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

標(biāo)題:隨意組合

小明被綁架到X星球的巫師W那里。

其時(shí),W正在玩弄兩組數(shù)據(jù) (2 3 5 8) 和 (1 4 6 7)
他命令小明從一組數(shù)據(jù)中分別取數(shù)與另一組中的數(shù)配對(duì),共配成4對(duì)(組中的每個(gè)數(shù)必被用到)。
小明的配法是:{(8,7),(5,6),(3,4),(2,1)}

巫師凝視片刻,突然說這個(gè)配法太棒了!

因?yàn)?#xff1a;
每個(gè)配對(duì)中的數(shù)字組成兩位數(shù),求平方和,無論正倒,居然相等:
872 + 562 + 342 + 212 = 12302
782 + 652+ 432 + 122 = 12302

小明想了想說:“這有什么奇怪呢,我們地球人都知道,隨便配配也可以啊!”
{(8,6),(5,4),(3,1),(2,7)}

862 + 542 + 312 + 272 = 12002
682 + 452 + 132 + 722 = 12002

巫師頓時(shí)凌亂了。。。。。

請(qǐng)你計(jì)算一下,包括上邊給出的兩種配法,巫師的兩組數(shù)據(jù)一共有多少種配對(duì)方案具有該特征。
配對(duì)方案計(jì)數(shù)時(shí),不考慮配對(duì)的出現(xiàn)次序。
就是說:
{(8,7),(5,6),(3,4),(2,1)}

{(5,6),(8,7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^^^ 01.^ ^ 1 1^^ ^.^1 1 0... 1 ^1 1^ ^ .01 ^ 1.. 1.1 ^0.0^ 0 1..01^^100000..0^1 1 ^ 1 ^^1111^ ^^0 ^ ^ 1 1000^.1 ^.^ . 00.. 1.1 0. 01. . 1. .^1. 1 1. ^0^ . ^.1 00 01^.0 001. .^*/ // VB_king —— 2016_Finals_A_1.cpp created by VB_KoKing on 2019-05-04:19. /* Procedural objectives:Variables required by the program:Procedural thinking:(2 3 5 8) 和 (1 4 6 7) 取數(shù)配對(duì),明顯是一個(gè)排列問題2分別與1 4 6 7配對(duì),然后3與剩下的三個(gè)數(shù)配對(duì),5與剩下的兩個(gè)數(shù)配對(duì),8與剩下的一個(gè)數(shù)配對(duì)。也就是說,總情況有4*3*2*1=24種換種思路,第一個(gè)數(shù)列的全排列與第二個(gè)數(shù)列的全排列進(jìn)行組合,然后判斷兩個(gè)平方和是否相等,之后在去重。再思考一下,第一個(gè)數(shù)列的全排列已經(jīng)能夠組合出所有的情況了。Functions required by the program:*/ /* My dear Max said: "I like you, So the first bunch of sunshine I saw in the morning is you, The first gentle breeze that passed through my ear is you, The first star I see is also you. The world I see is all your shadow."FIGHTING FOR OUR FUTURE!!! */ #include <iostream> #include <algorithm> using namespace std; int main() {int ans=0,num0[4]={2,3,5,8},num1[4]={1,4,6,7};do {int a=num0[0]*10+num1[0],b=num0[1]*10+num1[1],c=num0[2]*10+num1[2],d=num0[3]*10+num1[3];int e=num1[0]*10+num0[0],f=num1[1]*10+num0[1],g=num1[2]*10+num0[2],h=num1[3]*10+num0[3];if (a*a+b*b+c*c+d*d==e*e+f*f+g*g+h*h){ans++;cout<<a<<"^2^+"<<b<<"^2^+"<<c<<"^2^+"<<d<<"^2^="<<a*a+b*b+c*c+d*d<<endl;cout<<e<<"^2^+"<<f<<"^2^+"<<g<<"^2^+"<<h<<"^2^="<<e*e+f*f+g*g+h*h<<endl;cout<<endl;}}while (next_permutation(num0,num0+4));cout<<ans<<endl;return 0; }

總結(jié)

以上是生活随笔為你收集整理的2016年第七届蓝桥杯C/C++ A组国赛 —— 第一题:随意组合的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。