题目链接:http://acm.zzuli.edu.cn/zzuliacm/problem.php?cid=1157&pid=2 Description 985走入了一个n * n的方格地图,他已经知道其中有一个格子是坏的.现在他要从(1, 1)走到(n, n),每次只可以向下或者向右走一步,问他能否到达(n,n).若不能到达输出-1,反之输出到达(n,n)的方案数.   Input 第一行输入一个整数t,代表有t组测试数据. 每组数据第一行输入三个整数n,x,y,分别代表方格地图的大小以及坏掉…
 算法训练 A+B Problem   时间限制:1.0s   内存限制:512.0MB      问题描述 输入A,B. 输出A+B. 输入格式 输入包含两个整数A,B,用一个空格分隔. 输出格式 输出一个整数,表示A+B的值. 样例输入 5 8 样例输出 13 数据规模和约定 -1,000,000,000<=A,B<=1,000,000,000. import java.util.Scanner; public class Main { public static void main(St…
2019 Multi-University Training Contest 2: 1010 Just Skip The Problem 自闭记 题意 多测.每次给你一个数\(n\),你可以同时问无数次,每次问的是一个数\(y_i\),你会得到的回答是\(x\&y_i\)是否为\(y_i\),问你问的最少的次数的种数\(\%1e6+3\),可以调换顺序 10min 得出数学方法 求\(n!\%1e6+3\). 50min 自闭 5min 写出裸暴力,优化10min,交一发TLE 30min 网上…
HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有m个限制,每次限制要求在区间[l,r]内不同的点的个数是为x个,问你填完这n个空的并且满足限制的方案数 题解: 定义\(dp[i][j][k][t]\)表示在区间填完前t个位置后,{0,1,2,3}这四个数字最后一次出现的位置为i,j,k,t的方案数 滚动数组优化掉第一维后,我们转移如下 dp[p]…
HDU6579 2019HDU多校训练赛第一场1002 (线性基) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6579 题意: 两种操作 1.在序列末尾添加一个数 2.查询区间异或最大值 强制在线 题解: 暴力的做法可以用数据结构维护区间线性基,但肯定过不了. 贪心地维护序列的前缀线性基 (上三角形态),对于每个线性基,将出现位置靠右的数 字尽可能地放在高位,也就是说在插入新数字的时候,要同时记录对应位置上数字的出现位 置,并且在找到可以插入的位…
HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6621 题意: 给你n个数,有m次询问 每次问你在区间[l,r]内 第k小的|\(a_i-p\)|是多少 题解: 主席树+二分 每次二分答案 如果p+mid到p-mid的值的个数大于k个的话,mid值就是可行了,然后缩小区间往左找即可 因为保证有解,所以二分出来的mid值就是答案了 que…
题目链接:http://acm.zzuli.edu.cn/zzuliacm/problem.php?id=1908 题意:如果'.'被'*'围起来,就把'.'变为'*'. 分析:如果是'*'直接输出,如果是'.' 则要对其搜索 如果四个方向都是封闭的,则可以改变.即w[i][j]=4; 如果查询的是'*'或者查询的是已被查询过的'.'  ,则记录上: 如果查询的是'.'而且没有查询标记过,则进行查询: #include<iostream> #include<algorithm> #…
题目链接:http://acm.zzuli.edu.cn/zzuliacm/problem.php?cid=1158&pid=0 zzuli 1905  题意:如果k=1的话是1,2,3,4...n-1,n,n-1...3,2,1.可以看出这个周期是2*n-2,所以只要gcd(2*n-2, k)==1就是可以全部标记完的. 因为走到一个走过的并且方向一样并且没有标记全部的话就不可能能标记完了,所以要走2*n-2次没有重复位置和方向的,也就是gcd(2*n-2,k)==1. Sample Inpu…
2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D Problem D. Distribution in Metagonia Input file: distribution.in Output file: distribution.out Time limit: 2 seconds Memory limit: 256 megabytes There are one hundred noble families in the cou…
1001  Another Meaning 题意:字符串A中包含的字符串B可以翻译或不翻译,总共有多少方案. 题解:动规,dp[i]表示A的第i位为止有多少方案. 转移方程: dp[i]=dp[i-1](不翻译) dp[i]+=dp[i-B.size()](翻译i结尾的子串B) 初始条件:dp[0]=1(代表不翻译的这种情况) dp[B.size()]=2(若从A起点开始的子串是B,则有翻译和不翻译两种) //http://acm.hdu.edu.cn/showproblem.php?pid=5…
1009 I am your Father! (最小树形图-朱刘算法) 题目链接 HDU6141 I am your Father! 求有向图最大生成树,要求n的父节点尽量小. 我们将所有wi变为-wi,这题就变成了有向图最小生成树的模板题.对于f(n)尽可能小的要求,可以令所有wi扩大1000倍,然后 对于yi=n的点将1000-xi计入wi中,这样就保证了在W尽可能大的情况下f(n)尽可能小.有向图最小生成树的部分我们可以 O(nm)解决,大体思路是先找到每个点边权最小的父向边,然后这样连边…
1002 Build a tree(递归) 题目链接 HDU6121 Build a tree 有一棵n个点的有根树,标号为0到n-1,i号点的父亲是\(\lfloor\frac{i-1}{k}\rfloor\)号点,求所有子树大小的异或和.\(1\leq n,k\leq10^{18}\). 找出n所在的链,然后从根开始递归处理. k=1的时候特判,1异或到n,每4个异或起来为0. #include<bits/stdc++.h> #define ll long long using names…
1001 Is Derek lying 题目链接 HDU6045 Is Derek lying? 给出两个人选择题的回答,问得分分别为x和y是否可能.(\(1\le N \le 80000,0\le x,y \le N\)) 答案相同的部分,得分一定一样:答案不同的部分(dif个),是造成差距的地方.差距不可能超过不同的个数.分低者(y分)若成绩超过相同部分,那么不同部分也拿了分(y-sam).分高者最多还能拿剩下的不同部分的分(dif-(y-sam)).也就是最大分差为dif-(y-sam)-…
1001 Add More Zero(签到题) 题目链接 HDU6033 Add More Zero 找出最大的k,使得\(2^m-1\ge 10^k\). 直接取log,-1可以忽略不计. #include <cstdio> #include <cmath> int cas,m; int main(){ while(~scanf("%d",&m)){ printf("Case #%d: %d\n",++cas,(int)(m*log…
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8506#problem/A problem description As we know, the NTU Final PK contest usually tends to be pretty hard. Many teams got frustrated when participating NTU Final PK contest. So I decide to make the fi…
ZCC Loves Codefires Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 790    Accepted Submission(s): 420 Problem Description Though ZCC has many Fans, ZCC himself is a crazy Fan of a coder, called…
Couple doubi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1087    Accepted Submission(s): 762 Problem Description DouBiXp has a girlfriend named DouBiNan.One day they felt very boring and dec…
Balala Power! Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 3757    Accepted Submission(s): 907 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters. H…
Function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 273    Accepted Submission(s): 99 Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1. De…
这场题极其简单 Solved 19 / 19 A Gym 102035A N integers 略 Solved 10 / 33 B Gym 102035B Mahmoud the Thief 用map记录所有数%m的出现次数,然后按顺序模拟,如果不同模数的种类数只剩下一种,那么就结束 Solved 2 / 14 C Gym 102035C Apple Shops 二分最大的价格 Solved 18 / 31 D Gym 102035D Coach Ayoub 略 Solved 15 / 62…
Nice boat Time Limit: 30000/15000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 47 Accepted Submission(s): 10 Problem Description There is an old country and the king fell in love with a devil. The devil always ask…
Hotaru's problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 907    Accepted Submission(s): 322 Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playing…
The shortest problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 346    Accepted Submission(s): 167 Problem Description In this problem, we should solve an interesting game. At first, we hav…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6331 Walking Plan  Problem Description There are n intersections in Bytetown, connected with m one way streets. Little Q likes sport walking very much, he plans to walk for q days. On the i -th day, Little…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6325                                   Interstellar Travel Problem Description After trying hard for many years, Little Q has finally received an astronaut license. To celebrate the fact, he intends to buy…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322 Problem Description In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n that are relatively prime to n . It can be defined more formally as the number…
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/C 代码如下: #include <iostream> #include <algorithm> #include <stdio.h> #include <cstring> #include <queue> #include <bitset> #include <set> #include &l…
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52310 problem description Define the depth of a node in a rooted tree by applying the following rules recursively: • The depth of a root node is 0. • The depths of child nodes whose parents are with…
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem  description In ICPCCamp, there are n cities and (n−1) (bidirectional) roads between cities. The i-th road is between the ai-th and bi-th cities. It is guaranteed that cities are conne…
A:Pythagoras's Revenge 代码: #include<cstdio> #define ll long long using namespace std; int main() { ll a; while(scanf("%lld",&a)!=EOF) { ) break; ll aa=a*a; ; ;i<a;i++) { ll x=i; ) continue; ll y=aa/i; !=) continue; >a) ans++; } p…