2015年第六届蓝桥杯C/C++ A组国赛 —— 第一题:方格填数
生活随笔
收集整理的這篇文章主要介紹了
2015年第六届蓝桥杯C/C++ A组国赛 —— 第一题:方格填数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
標題:方格填數
在2行5列的格子中填入1到10的數字。
要求:
相鄰的格子中的數,右邊的大于左邊的,下邊的大于上邊的。
如【圖1.png】所示的2種,就是合格的填法。
請你計算一共有多少種可能的方案。
請提交該整數,不要填寫任何多余的內容(例如:說明性文字)。
Code
/*^....0^ .1 ^1^.. 011.^ 1.0^ 1 ^ ^0.11 ^ ^..^0. ^ 0^.0 1 .^.1 ^0 .........001^.1 1. .111100....01^00 11^ ^1. .1^1.^ ^0 0^.^ ^0..1.1 1..^1 .0 ^ ^00. ^^0.^^ 0 ^^110.^0 0 ^ ^^^10.01^^ 10 1 1 ^^^1110.101 10 1.1 ^^^1111110010 01 ^^ ^^^1111^1.^ ^^^10 10^ 0^ 1 ^^111^^^0.1^ 1....^11 0 ^^11^^^ 0.. ....1^ ^ ^1. 0^ ^11^^^ ^ 1 111^ ^ 0.10 00 11 ^^^^^ 1 0 1.0^ ^0 ^0 ^^^^ 0 0.0^ 1.0 .^ ^^^^ 1 1 .0^.^ ^^ 0^ ^1 ^^^^ 0. ^.11 ^ 11 1. ^^^ ^ ^ ..^^..^ ^1 ^.^ ^^^ .0 ^.00..^ ^0 01 ^^^ .. 0..^1 .. .1 ^.^ ^^^ 1 ^ ^0001^ 1. 00 0. ^^^ ^.0 ^.1. 0^. ^.^ ^.^ ^^^ ..0.01 .^^. .^ 1001 ^^ ^^^ . 1^. ^ ^. 11 0. 1 ^ ^^ 0.0 ^. 0 ^0 1 ^^^ 0.0.^ 1. 0^ 0 .1 ^^^ ...1 1. 00 . .1 ^^^ ..1 1. ^. 0 .^ ^^ ..0. 1. .^ . 0 ..1 1. 01 . . ^ 0^.^ 00 ^0 1. ^ 1 1.0 00 . ^^^^^^ ..^ 00 01 ..1. 00 10 1 ^^.1 00 ^. ^^^ .1.. 00 .1 1..01 ..1.1 00 1. ..^ 10^ 1^ 00 ^.1 0 1 1.1 00 00 ^ 1 ^. 00 ^.^ 10^ ^^1.1 00 00 10^..^ 1. ^. 1.0 1 ^. 00 00 .^^ ^. ^ 1 00 ^0000^ ^ 011 0 ^. 00.0^ ^00000 1.00.1 11. 1 0 1^^0.01 ^^^ 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 —— 2015_Finals_A_C++_1.cpp created by VB_KoKing on 2019-05-15:09. /* Procedural objectives:Variables required by the program:Procedural thinking:Functions required by the program:Determination algorithm:Determining data structure:*/ /* 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 <algorithm> #include <iostream>using namespace std;int main() {long long ans = 0;int num[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};do {if (num[0] < num[1] && num[1] < num[2] && num[2] < num[3] && num[3] < num[4]&& num[5] < num[6] && num[6] < num[7] && num[7] < num[8] && num[8] < num[9]&& num[0] < num[5] && num[1] < num[6] && num[2] < num[7] && num[3] < num[8] && num[4] < num[9]) {for (int j = 0; j < 5; j++)cout << num[j] << ' ';cout << endl;for (int j = 0; j < 5; j++)cout << num[j + 5] << ' ';cout << endl << endl;ans++;}} while (next_permutation(num, num + 10));cout << ans << endl;return 0; }總結
以上是生活随笔為你收集整理的2015年第六届蓝桥杯C/C++ A组国赛 —— 第一题:方格填数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2017年第八届蓝桥杯C/C++ B组国
- 下一篇: 2016年第七届蓝桥杯 - 国赛 - J