藍橋杯 入門訓練四道題

2021-08-15 14:40:06 字數 892 閱讀 8333

重點:在本題中,答案是要求fn除以10007的餘數,因此我們只要能算出這個餘數即可,而不需要先計算出fn的準確值, 再將計算的結果除以10007取餘數,直接計算餘數往往比先算出原數再取餘簡單。

這句話已經告訴你怎麼寫程式了!

#include 

using

namespace

std;

int main()

}cout

<< f3 0;}

這道題關鍵在與小數點的精確度,我用的是c++寫的,所有需要知道c++double精度如何控制:

第一種方法:

cout<<<第二種方法:

cout.precision(dbl:

:digits);

接下來就簡單了,解題**:

#include

#include

using

namespace

std;

int main()

這道題沒啥說的,主要是用暴力的求解方式肯定會出現超時,或者記憶體占用過大的問題。

#include

#include

using

namespace

std;

int main()

看過其中的內容了解知道後,直接貼上複製嘍!

#include 

using

namespace

std;

int main()

藍橋杯練題系統 入門訓練

給定圓的半徑r,求圓的面積。輸入包含乙個整數r,表示圓的半徑。輸出一行,包含乙個實數,四捨五入保留小數點後7位,表示圓的面積。50.2654825 1 r 10000。本題對精度要求較高,請注意 的值應該取較精確的值。你可以使用常量來表示 比如pi 3.14159265358979323,也可以使用...

藍橋杯入門訓練

1.a b問題 include int main 2.序列求和問題 include int main 3.圓的面積問題 include include define pi atan 1.0 4 int main 4.fibonacci數列 include int main 注意陣列的長度100000...

藍橋杯 入門訓練

begin 1 a b問題 include using namespace std inta,b intmain view code begin 2 序列求和 include using namespace std long long n long long ans 0 int main view ...