精品偷拍一区二区三区,亚洲精品永久 码,亚洲综合日韩精品欧美国产,亚洲国产日韩a在线亚洲

  • <center id="usuqs"></center>
  • 
    
  • 杭電ACM1005 Number Sequence

    杭電ACM1005 Number Sequence
    A number sequence is defined as follows:
    f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.
    Given A, B, and n, you are to calculate the value of f(n).

    Input
    The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1
    其他人氣:862 ℃時(shí)間:2020-06-16 02:25:29
    優(yōu)質(zhì)解答
    /*1 1 321 2 1050 0 0Press any key to continue*/#include<stdio.h>int main(void) {\x09int a1 = 1,a2 = 1,an;\x09int A,B,n,i;\x09while(1) {\x09\x09scan...似乎不優(yōu)化一下會(huì)超時(shí)

    // 簡(jiǎn)單修改了下,再超時(shí)的話,我就沒(méi)有個(gè)別更好的方法了。

    #include<stdio.h>
     
    int main(void) {
    int A,B,n,i,an_1,an_2,an;
    while(scanf("%d%d%d",&A,&B,&n) == 3 && n) {
    an_1 = 1;
    an_2 = 1;
    for(i = 3; i <= n; ++i) {
    an = (A * an_2 + B * an_1) % 7;
    an_1 = an_2;
    an_2 = an;
    }
    printf("%d\n",an);
    }
        return 0;
    }
    我來(lái)回答
    類似推薦
    請(qǐng)使用1024x768 IE6.0或更高版本瀏覽器瀏覽本站點(diǎn),以保證最佳閱讀效果。本頁(yè)提供作業(yè)小助手,一起搜作業(yè)以及作業(yè)好幫手最新版!
    版權(quán)所有 CopyRight © 2012-2024 作業(yè)小助手 All Rights Reserved. 手機(jī)版