2501. 算算式

來源:互聯網
上載者:User

2501. 算算式

Description

_gXX遇到一個麻煩的式子:S = n1 + n2 + n3 + ...... + nk,已知n、k,求S的值。因為_gXX數學很差,希望你能告訴他答案。但是由於他的數學實在太差了,所以你只需要告訴他S除以9901的餘數即可。

Input

兩個整數,n和k(n ≤ 1000 , k ≤ 109)。

Output

一個數,表示S除以9901的餘數。

Sample Input

2 3
Sample Output

14
Problem Source

黃金周賽——省賽最後的衝刺

費馬小定理,若a為整數,p為質數,則 ,
即迴圈等於1,9901為素數,因此只需計算k模9900個數的和的模。

#include <iostream>using namespace std;int main(){    int n,k;    cin>>n>>k;    int m=k%9900,sum=0;    for (int i=0;i<m;i++)    {sum=(sum+1)*n;        sum%=9901;    }    cout<<sum<<endl;    return 0;} 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.