HDU1005

作者: 眼镜猫头鹰 | 来源:发表于2020-09-15 16:40 被阅读0次

import java.util.Scanner;

/**

  • Created by mac on 2018/12/1.
    */
    public class Main {
    public static void main(String[]args){
    Scanner input = new Scanner(System.in);
    int a,b,n;
    while(true){
    a = input.nextInt();
    b = input.nextInt();
    n = input.nextInt();
    if (a < 1 & a > 1000 & b < 1 & b > 1000 & b < 1 & a > 100000000)
    System.exit(0);
    if (a == 0 && b ==0 && n == 0) break;
    int f[] = new int[50];
    for (int i = 1; i < 50; i++) {
    if (i == 1 || i == 2) {
    f[i] = 1;
    } else {
    f[i] = (a * f[i - 1] + b * f[i - 2]) % 7;
    }
    }
    System.out.println(f[n % 49]);
    }
    input.close();
    }
    }

相关文章

  • HDU1005

    import java.util.Scanner; /** Created by mac on 2018/12/1...

  • hdu1005 矩阵快速幂

    题目 Number Sequence Problem Description A number sequence ...

网友评论

    本文标题:HDU1005

    本文链接:https://www.haomeiwen.com/subject/lspfyktx.html