2013年第四届蓝桥杯C/C++ A组国赛 —— 第三题:埃及分数
生活随笔
收集整理的這篇文章主要介紹了
2013年第四届蓝桥杯C/C++ A组国赛 —— 第三题:埃及分数
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
標(biāo)題:埃及分?jǐn)?shù)
古埃及曾經(jīng)創(chuàng)造出燦爛的人類(lèi)文明,他們的分?jǐn)?shù)表示卻很令人不解。古埃及喜歡把一個(gè)分?jǐn)?shù)分解為類(lèi)似: 1/a + 1/b 的格式。
這里,a 和 b 必須是不同的兩個(gè)整數(shù),分子必須為 1
比如,2/15 一共有 4 種不同的分解法(姑且稱(chēng)為埃及分解法):
1/8 + 1/120
1/9 + 1/45
1/10 + 1/30
1/12 + 1/20
那么, 2/45 一共有多少個(gè)不同的埃及分解呢(滿(mǎn)足加法交換律的算同種分解)? 請(qǐng)直接提交該整數(shù)(千萬(wàn)不要提交詳細(xì)的分解式!)。
請(qǐng)嚴(yán)格按照要求,通過(guò)瀏覽器提交答案。
注意:只提交分解的種類(lèi)數(shù),不要寫(xiě)其它附加內(nèi)容,比如:說(shuō)明性的文字
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++_3.cpp created by VB_KoKing on 2019-05-10:08. /* 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>using namespace std;int main() {int ans = 0;for (int a = 1; a < 10000; a++) {for (int b = a + 1; b < 10000; b++) {if (45 * (a + b) == 2 * a * b) {ans++;cout << "2/45" << '=' << 1 << '/' << a << '+' << 1 << '/' << b << endl;}}}cout << ans << endl;return 0; }總結(jié)
以上是生活随笔為你收集整理的2013年第四届蓝桥杯C/C++ A组国赛 —— 第三题:埃及分数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 2013年第四届蓝桥杯C/C++ A组国
- 下一篇: 2016年第七届蓝桥杯C/C++ A组国