hdu_5551_多校联赛5_1009
2015-08-04 22:06
309 查看
把表打出来一部分,轻松找到规律即可。
[code]import java.util.Scanner; import java.math.BigInteger; import java.math.BigDecimal; public class Main{ public static void main(String []args){ Scanner cin=new Scanner(System.in); int t; BigInteger a[]=new BigInteger[1011]; a[1]=BigInteger.ONE; a[2]=BigInteger.ONE; for(int i=3;i<=1010;i++){ a[i]=a[i-1].add(a[i-2]); } int n; t=cin.nextInt(); BigInteger two=new BigInteger("2"); BigInteger mo=new BigInteger("258280327"); BigInteger sum,tmp,m; while(t!=0){ t--; n=cin.nextInt(); m=cin.nextBigInteger(); sum= new BigInteger("0"); for(int i=1;i<=1000;i++){ tmp=a[i].multiply(two); int res = m.compareTo(tmp); if(res>0){ m=m.subtract(tmp); sum=sum.add(tmp); } else{ res = m.compareTo(a[i]); if(res>0) System.out.println(sum.divide(two).add(m).subtract(a[i]).subtract(BigInteger.ONE).mod(mo)); else System.out.println(sum.divide(two).add(m).subtract(BigInteger.ONE).mod(mo)); break; } } } } }
相关文章推荐
- cause:Permission Denial: receiving Intent act=android.provider.Telephony.SMS_RECEIVED
- 多线程1
- Count the Trees 典型卡特兰数
- 【Objective-C编程】import、include及@Class的孽缘
- VistualStudio 2005 设置PowerBuilder12.5 PBNI编绎命令行。
- 浅谈WebView
- Docker 容器日志的那些事儿
- 【Mac版】安装 Android Studio 及配置环境变量步骤
- 没做过编译器就是被人欺——从一道变态的i++题猜编译器的行为(表达式从左往右扫描,同一变量相互影响)
- 关于foreach的一个BUG
- leetcode面试准备:Count Complete Tree Nodes
- Struts拦截器拦截未登录的操作
- sudo 问题
- 黑马程序员--文件字符输入输出函数的应用
- day04_循环结构_20150804
- 获取鼠标XY坐标
- 例子
- FileInputStream与FileOutputStream练习题 -------------------图片拷贝
- Lua在iOS上的编译
- 选数