2013年第四届蓝桥杯C/C++ A组国赛 —— 第一题:填算式
生活随笔
收集整理的這篇文章主要介紹了
2013年第四届蓝桥杯C/C++ A组国赛 —— 第一题:填算式
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
標題:填算式
請看下面的算式:
(ABCD - EFGH) * XY = 900
每個字母代表一個0~9的數字,不同字母代表不同數字,首位不能為0。
比如,(5012 - 4987) * 36 就是一個解。
請找到另一個解,并提交該解中 ABCD 所代表的整數。
請嚴格按照格式,通過瀏覽器提交答案。
注意:只提交 ABCD 所代表的整數,不要寫其它附加內容,比如:說明性的文字。
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 —— 2013_Finals_A_C++_1.cpp created by VB_KoKing on 2019-05-09:10. /* 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 <iostream> #include <algorithm>using namespace std;int main() {int num[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};do {if (num[0] == 0 || num[4] == 0 || num[8] == 0) continue;int ABCD = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3];int EFGH = num[4] * 1000 + num[5] * 100 + num[6] * 10 + num[7];int XY = num[8] * 10 + num[9];if ((ABCD - EFGH) * XY == 900) {cout << '(' << ABCD << " - " << EFGH << ')' << " * " << XY << " = " << (ABCD - EFGH) * XY << endl;cout << "ABCD=" << ABCD << endl;}} while (next_permutation(num, num + 10));return 0; }總結
以上是生活随笔為你收集整理的2013年第四届蓝桥杯C/C++ A组国赛 —— 第一题:填算式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2017年第八届蓝桥杯C/C++ C组国
- 下一篇: 2013年第四届蓝桥杯C/C++ A组国