SYSU_1620
来源:互联网 发布:豫广网络维修电话 编辑:程序博客网 时间:2024/06/05 05:53
省赛前最后一场练习赛
J题:
水题,左右互相打求剩余数
水题不猜题.
C题
给出n,求sigma( A(2,n) + A(3,n) +…+A(n,n))
高精度.错了很多次的缘故是没有检查最小加数(longlong)的合理性
E题
反密码…按照要求走一遍
G题
求比给出数大的 最小的 数
1.从右往左扫得到第一个可以减的数
2.从可减的数往左扫得到第一个可以加的数
3.可以加的数右边最小排列
H题
求’1’,’2’组成的可以被2^n整除的数
目测高精度除法+乘法..一堆人用Java/Python过了..
JavaBig
//javahttp://lavasoft.blog.51cto.com/62575/228705package lavasoft; import java.math.BigInteger; import java.util.Random; /** * 测试BigInteger * * @author leizhimin 2009-11-17 12:49:41 */ public class TestBigInteger { public static void main(String[] args) { System.out.println("-------------------构造BigInteger---------------------"); //通过byte数组来创建BigInteger BigInteger bi1 = new BigInteger(new byte[]{1, 1}); System.out.println("bi1=" + bi1.toString()); //创建带符号的BigInteger BigInteger bi2 = new BigInteger(-1, new byte[]{1, 1}); System.out.println("bi2=" + bi2.toString()); //创建带符号的BigInteger随机数 BigInteger bi3 = new BigInteger(128, 20, new Random()); System.out.println("bi3=" + bi3.toString()); //通过10进制字符串创建带符号的BigInteger BigInteger bi4 = new BigInteger("12342342342342123423423412341"); System.out.println("bi4=" + bi4.toString()); //通过10进制字符串创建带符号的BigInteger BigInteger bi5 = new BigInteger("88888888888888888888888888888", Character.digit('a', 33)); System.out.println("bi5=" + bi5.toString()); System.out.println("BigInteger的常量:"); System.out.println("BigInteger.ZERO=" + BigInteger.ZERO); System.out.println("BigInteger.ONE=" + BigInteger.ONE); System.out.println("BigInteger.TEN=" + BigInteger.TEN); System.out.println("-------------------使用BigInteger---------------------"); System.out.println("bi1的相反数=" + bi1.negate()); System.out.println("bi1的相反数=" + bi1.negate()); System.out.println("bi1+bi2=" + bi1.add(bi2)); System.out.println("bi1-bi2=" + bi1.subtract(bi2)); System.out.println("bi1*bi2=" + bi1.multiply(bi2)); System.out.println("bi1/bi2=" + bi1.divide(bi2)); System.out.println("bi1的10次方=" + bi1.pow(10)); System.out.println("bi1的10次方=" + bi1.pow(1)); BigInteger[] bx = bi4.divideAndRemainder(bi1); System.out.println(">>>:bx[0]=" + bx[0] + ",bx[1]=" + bx[1]); System.out.println("bi2的绝对值=" + bi2.abs()); } }
D题
理解错题意:第N天前分发而不是恰好第N天分发
主要思路是从截止日开始倒着扫,而不是从最后倒着扫
sort(D,D+tot); for (int i = 0; i < tot; ++i) { for (int j = D[i].day; j >= 1; j--) { if (cnt[j] == 0) { cnt[j] = D[i].ori; break; } } }
0 0