zoukankan      html  css  js  c++  java
  • POJ1942+找规律

    View Code
     1 import java.util.*;
     2 import java.math.*;
     3 import java.text.*;
     4 import java.io.* ;
     5 
     6 public class Main{
     7     public static void main( String args[] ){
     8         BigInteger n,m,tq;
     9         Scanner cin = new Scanner(new BufferedInputStream(System.in)); 
    10         while( cin.hasNext() ){
    11             n = cin.nextBigInteger();
    12             m = cin.nextBigInteger();
    13             if( (String.valueOf(n)).compareTo(String.valueOf(BigInteger.valueOf(0)))==0 && (String.valueOf(m)).compareTo(String.valueOf(BigInteger.valueOf(0)))==0 )
    14                     break;
    15             if( (String.valueOf(n)).compareTo(String.valueOf(BigInteger.valueOf(0)))==0||(String.valueOf(m)).compareTo(String.valueOf(BigInteger.valueOf(0)))==0 ){
    16                 System.out.println("1");
    17                 continue;
    18             }
    19             if( (String.valueOf(n)).compareTo(String.valueOf(m))<0 ){
    20                 tq = n;
    21                 n = m;
    22                 m = tq;
    23             }
    24             BigInteger res;
    25             res = BigInteger.valueOf(1);
    26             n = n.add( m );
    27             BigInteger i ;
    28             i = BigInteger.valueOf(1);
    29             //System.out.println( i );
    30             //System.out.println( n );
    31             while( true ){
    32                 res = res.multiply(n);
    33                 res = res.divide(i);
    34                 n = n.subtract(BigInteger.valueOf(1));
    35                 i = i.add(BigInteger.valueOf(1));
    36                 if( (String.valueOf(i)).compareTo(String.valueOf(m.add(BigInteger.valueOf(1))))==0 ) break;
    37                 //System.out.println( res );
    38             }
    39             System.out.println( res );
    40         }
    41     }
    42 }
    43             
    44                 
    45             

    C(n,m+n)

    keep moving...
  • 相关阅读:
    学习笔记:松弛
    学习笔记:可持久化线段树
    poj 3784 Running Median
    学习笔记:树状数组
    poj 2823 Sliding Window 题解
    学习笔记:状态压缩DP
    学习笔记:单调队列
    C++ 竞赛常用头文件
    mongodb lock 出毛病时解决方法
    ag使用需要注意的问题
  • 原文地址:https://www.cnblogs.com/xxx0624/p/3069818.html
Copyright © 2011-2022 走看看