• FZU 2278 概率


    题目分析:http://acm.fzu.edu.cn/problem.php?pid=2278

     1 import java.math.BigInteger;
     2 import java.util.Scanner;
     3 
     4 public class Main {
     5     public static void main(String[] args) {
     6         Scanner sc=new Scanner(System.in);
     7         int T=sc.nextInt();
     8         int []a = new int[2010];
     9         int cnt=0;
    10         while (T>0)
    11         {
    12             int n=sc.nextInt();
    13             int m=sc.nextInt();
    14             BigInteger ans=BigInteger.valueOf(m);
    15             BigInteger card=BigInteger.valueOf(0);
    16             for (int i = 0; i < n; i++) a[i] = sc.nextInt();
    17             for (int i = 0; i < n; i++)
    18             {
    19                 if (a[i+1]>a[i])
    20                 {
    21                     card = card.add(ans.divide(BigInteger.valueOf(a[i])));
    22                     ans = ans.mod(BigInteger.valueOf(a[i]));
    23                 }
    24                 else
    25                 {
    26                     ans = ans.add(card.multiply(BigInteger.valueOf(a[i])));
    27                     card = BigInteger.valueOf(0);
    28                 }
    29             }
    30             System.out.printf("Case #%d: ",++cnt);
    31             System.out.println(ans.mod(BigInteger.valueOf(1000000007)));
    32             T--;
    33         }
    34     }
    35 }
  • 相关阅读:
    xp 安装 win7 64
    局域网内传输文件速度慢
    安全和共享设置
    vs2005无法启动
    dos快速通道
    xp 共享 guest
    Java菜题
    Java序列化总结(最全)
    Bitset改进你的程序质量
    Java反射方法总结
  • 原文地址:https://www.cnblogs.com/poler/p/7275605.html
Copyright © 2020-2023  润新知