2014年第五届蓝桥杯C/C++ A组国赛 —— 第一题:海盗分金币
生活随笔
收集整理的這篇文章主要介紹了
2014年第五届蓝桥杯C/C++ A组国赛 —— 第一题:海盗分金币
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
標題:海盜分金幣
有5個海盜,相約進行一次帆船比賽。
比賽中天氣發生突變,他們被沖散了。
恰巧,他們都先后經過途中的一個無名的荒島,并且每個人都信心滿滿,覺得自己是第一個經過該島的人。
第一個人在沙灘上發現了一堆金幣。他把金幣分成5等份。發現剛好少一個金幣。他就從自己口袋拿出一個金幣補充進去,然后把屬于自己的那份拿走。
第二個到達的人也看到了金幣,他也和第一個人一樣,把所有金幣5等分,發現剛好缺少一個金幣,于是自己補進去一個,拿走了屬于自己的那份。
第三,第四,第五人的情況一模一樣。
等他們到了目的地,都說自己的情況,才恍然大悟,一起去荒島找金幣,然而再也沒有找到荒島。他們都惋惜地說:島上還有一千多枚金幣呢!
請你根據這些信息,推算荒島上最初有多少金幣?
這是一個整數,請通過瀏覽器提交答案,不要填寫任何多余的內容(比如說明性的文字等)
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 —— 2018_Finals_C_C++_3.cpp created by VB_KoKing on 2019-05-19:20. /* 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;bool check(int num){if(num%5!=4) return false;int _1=4*(num+1)/5;if(_1%5!=4) return false;int _2=4*(_1+1)/5;if(_2%5!=4) return false;int _3=4*(_2+1)/5;if(_3%5!=4) return false;int _4=4*(_3+1)/5;if(_4%5!=4) return false;int _5=4*(_4+1)/5;if(_5<1000 || _5>2000) return false;return true; }int main(){for(int i=1000;i<10000;i++){if(check(i))cout<<i<<endl;}return 0; }總結
以上是生活随笔為你收集整理的2014年第五届蓝桥杯C/C++ A组国赛 —— 第一题:海盗分金币的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2013年第四届蓝桥杯C/C++ A组国
- 下一篇: 2014年第五届蓝桥杯C/C++ A组国