A题:

一道dp的题目

dp[i][j] = k 代表 i行放j个棋子有k中可能

dp[i][j] = dp[i-1][0] + dp[i-1][1] + dp[i-1][2] +...dp[i-1][j]

初始 dp[1][0] = 1, dp[1][1] = 1

注意点:

  1. BigInteger 否则爆栈
  2. 最后return 从1开始加
import java.util.*;
import java.math.*; public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
BigInteger[][] dp = new BigInteger[110][110];
for (int i = 0;i <= 109; i++)
for(int j = 0;j <= 109; j++)
dp[i][j] = new BigInteger("0");
dp[1][0] = new BigInteger("1");
dp[1][1] = new BigInteger("1"); int n = sc.nextInt();
for (int i = 2; i <= n ;i++){
for (int j = 0; j <= i; j++){
for (int k = 0; k <= j; k++){
dp[i][j] = dp[i][j].add(dp[i-1][k]);
}
}
}
BigInteger ans = new BigInteger("0");
for (int i = 1; i <= n; i++)
ans = ans.add(dp[n][i]);
System.out.println(ans);
}
}

B题:用公式

不知道这个A的伴随矩阵公式,就很难受了- - 。。

import java.util.*;

public class Main2{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int i = 0; i < T; i++) {
int[][] A = new int[3][3];
for (int m = 0; m < 3; m ++) {
for (int n = 0; n < 3; n++) {
A[m][n] = sc.nextInt();
}
}
long ao = (A[0][0]* A[1][1]* A[2][2]) + (A[1][0]* A[2][1]* A[0][2]) + (A[2][0]* A[0][1]* A[1][2])
- (A[0][2]* A[1][1]* A[2][0]) - (A[0][0]* A[1][2]* A[2][1]) - (A[0][1]* A[1][0]* A[2][2]);
System.out.println(ao* ao);
}
}
}

C题:

一开始理解错了,他的意思是a^n,我还以为要a *=a;

import java.math.BigInteger;
import java.util.*; public class Main3{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int i = 0; i < T; i++) {
BigInteger a = new BigInteger("0"), n = new BigInteger("0"), b = new BigInteger("0");
a = sc.nextBigInteger();
n = sc.nextBigInteger();
b = sc.nextBigInteger();
System.out.println(a.modPow(n,b));
}
}
}

E题:

感觉巨他妈坑了,本来

××if (y1_xing == C)

××B --;

我都服了,被这个卡了小半天。。

import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*; public class Main{
static int y1_xing;
static boolean r;
static int ny, nm, nd;
static int[] monthofday = new int[]{-1,31,28,31,30,31,30,31,31,30,31,30,31};
static int res; //这个月的几号 public static boolean is_run(int year) {
if (year % 400 == 0 ||(year % 4 == 0 && year % 100 != 0))
return true;
return false;
} public static void gety1_xing(int ny,int y,int A, int B, int C) {
y1_xing = 1;
for (ny = 1850; ny < y; ny++) {
for (nm = 1; nm <= 12; nm ++) {
int month_ofday = monthofday[nm];
if(is_run(ny) && nm == 2) month_ofday += 1;
for(nd = 1; nd <= month_ofday; nd++) {
y1_xing += 1;
if (y1_xing == 8) y1_xing = 1;
}
}
}
for(nm = 1;nm < A;nm++) {
int month_ofday = monthofday[nm];
if(is_run(y) && nm == 2) month_ofday += 1;
for(nd = 1; nd <= month_ofday; nd++) {
y1_xing += 1;
if (y1_xing == 8) y1_xing = 1;
}
}
boolean has = false; int month_ofday = monthofday[nm];
if(is_run(y) && B == 2) month_ofday += 1; for (res = 1;res <= month_ofday; res++) {
y1_xing += 1;
if (y1_xing == 8) {
y1_xing = 1;
}
if (y1_xing == C)
B --; if (B == 0) {
has = true;
break;
} }
if(!has) res = -1;
} public static void main(String[] args) throws ParseException{
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), y = sc.nextInt();
gety1_xing(ny,y, A, B, C);
if (res != -1) {
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, y);
c.set(Calendar.MONTH, A - 1);
c.set(Calendar.DAY_OF_MONTH, res);
Date d=new Date();
d=c.getTime();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
String str=sdf.format(d);
System.out.println(str);
}
else
System.out.println("none");
}
}
}

H题:

先打表,在找规律!

import java.math.BigInteger;
import java.util.*; public class MainH{
//打表 -> 找规律!
//100 1-1 1-2 1-3 1-4....1-100
//99 1-1 1-2 1-3...1-99
//...
//2 1-1 1-2
//1 1-1
public static void main(String[] args){
/*
for(int i = 1; i <= 10 ; i++) {
int[] a = new int[i + 1]; //计数从1开始
//经过i次
for(int j = 2; j <= i; j++) {
for(int k = 1; k*j < a.length; k++) {
a[k*j] = 1 - a[k*j];
}
}
for (int j = 1; j <= i; j++) {
System.out.print(a[j]+" ");
}
System.out.println();
}*/ //找到规律:规律是:
//经过i次,为1的位置为:1 4 9 16 25 36 49 64 81 100 121 144
// A=1,B=3
//4 - 1 - 1 = 2, 9 - 4 - 1 =4,
//16 - 9 - 1 = 6, 25 - 16 - 1 = 8
//依次增长2 //1: 0 0 0 0 0
//2: 0 1 0 1 0
//3: 0 1 1 1 0
//4: 0 1 1 0 0
//5: 0 1 1 0 1 Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int i = 0; i < T; i++) {
long N = sc.nextLong(), A = sc.nextLong(),B = sc.nextLong();
int start = 1;
int gap = 2;
while (start < A) {
start += gap + 1;
gap += 2;
}
//start >= A
int res = 0;
while (start <= B) {
res ++;
start += gap + 1;
gap += 2;
}
System.out.println(B - A+1-res);
}
}
}

感觉没有练习过ACM 的确是做得磕磕拌拌,全是坑!!! 明天接着更剩下的题吧- - 。。

HEU预热赛的更多相关文章

  1. 哈尔滨工程大学ACM预热赛

    https://ac.nowcoder.com/acm/contest/554#question A #include <bits/stdc++.h> using namespace st ...

  2. 哈尔滨工程大学ACM预热赛(A,C,H,I)

    A: 链接:https://ac.nowcoder.com/acm/contest/554/A来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言655 ...

  3. 哈尔滨工程大学ACM预热赛 G题 A hard problem(数位dp)

    链接:https://ac.nowcoder.com/acm/contest/554/G Now we have a function f(x): int f ( int x ) {     if ( ...

  4. 哈尔滨工程大学ACM预热赛 补题

    链接:https://ac.nowcoder.com/acm/contest/554/A来源:牛客网 小虎刚刚上了幼儿园,老师让他做一个家庭作业:首先画3个格子,第二行有2个格子,第三行有1个格子. ...

  5. SCNU ACM 2016新生赛决赛 解题报告

    新生初赛题目.解题思路.参考代码一览 A. 拒绝虐狗 Problem Description CZJ 去排队打饭的时候看到前面有几对情侣秀恩爱,作为单身狗的 CZJ 表示很难受. 现在给出一个字符串代 ...

  6. C#中HttpClient使用注意:预热与长连接

    最近在测试一个第三方API,准备集成在我们的网站应用中.API的调用使用的是.NET中的HttpClient,由于这个API会在关键业务中用到,对调用API的整体响应速度有严格要求,所以对HttpCl ...

  7. SCNU ACM 2016新生赛初赛 解题报告

    新生初赛题目.解题思路.参考代码一览 1001. 无聊的日常 Problem Description 两位小朋友小A和小B无聊时玩了个游戏,在限定时间内说出一排数字,那边说出的数大就赢,你的工作是帮他 ...

  8. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  9. SCNU 2015ACM新生赛决赛【F. Oyk闯机关】解题报告

            题目大意:一个$N$$\times$$N$的阵列,每个格子有$X_{ij}$个调和之音,若每次只能选择走右边或下边,从左上角出发走到右下角,问最多能收集到多少个调和之音?       ...

随机推荐

  1. MongoDB-Oplog详解

    MongoDB Oplog 详解 Oplog 概念 Oplog 是用于存储 MongoDB 数据库所有数据的操作记录的(实际只记录增删改和一些系统命令操作,查是不会记录的),有点类似于 mysql 的 ...

  2. C语言第九讲,结构体

    C语言第九讲,结构体 一丶结构体的定义 在C语言中,可以使用结构体(Struct)来存放一组不同类型的数据.结构体的定义形式为: struct 结构体名{ 结构体所包含的变量或数组 }; 结构体是一种 ...

  3. 如何在线显示php源代码

    通过php提供的函数highlight_file和highlight_string实现

  4. python subprocess模块详解

    一.subprocess标准库 python执行shell脚本,通常会使用so模块中的几个方法,如system.spawn*.popen等.subprocess标准库的引入就是为了取代这些老的模块方法 ...

  5. fastdfs集群版搭建(一)- storage集群搭建与统一入口访问

    前言 接着上篇博客:详细的最新版fastdfs单机版搭建,今天来讲讲fastdfs的集群搭建,限于篇幅,今天先搭建stoarge集群,并实现统一的http访问方式: 没看我上篇博客的小伙伴,最好先去瞅 ...

  6. 【NET CORE微服务一条龙应用】第一章 网关使用与配置

    简介 微服务的系统应用中,网关系统使用的是ocelot,ocelot目前已经比较成熟了 ocelot就不做介绍了,等整体介绍完后再进行各类扩展介绍,ocelot源码地址:https://github. ...

  7. spring cloud zuul 传递 header

    最近在做一个项目时,发现在网关中调用和在子系统中调用request.getRequestURL()所得到的请求url是不一样的,在网关中得到的是通过域名访问的地址,而在子系统中得到的是网关发起的子系统 ...

  8. SQL Server 中的 NOLOCK 到底是什么意思?

    以前遇到过,但仅限于听同事说加上NOLOCK好一些,今天仔细研究测试了下,终于理解了,那么加与不加到底区别在哪呢? 我先说下其区别,之后再做测试. 大家都知道,每新建一个查询,都相当于创建一个会话,在 ...

  9. PowerDesigner 参照完整性约束(转载)

    PowerDesigner 参照完整性约束: 限制(Restrict):不允许进行修改或删除操作.若修改或删除主表的主键时,如果子表中存在子记录,系统将产生一个错误提示.这是缺省的参照完整性设置. 置 ...

  10. 设计模式之观察者模式(Observer)

    观察者模式通常的叫法叫做订阅-发布模式,类似于报刊杂志的订阅,观察者和被观察者就是读者和邮局的关系,读者先要在邮局订阅想要的报刊,当报刊发行时,邮局会将报刊邮寄到读者家里.观察者(Observer)和 ...