- 博客(115)
- 收藏
- 关注
原创 java LinkedList常用方法
import java.util.*;import java.io.*;import java.math.BigDecimal;import java.math.BigInteger;public class Main { public static void main(String []args) { Scanner cin=new Scanner(System.in); ...
2020-04-23 10:13:53
323
原创 Java实现对结构体自定义排序
一、下面代码实现:若x相等对y从小到大排。否则,对x从小到大排序 import java.lang.reflect.Array;import java.util.*;import java.math.BigInteger;//定义node类class node{ int x,y;}//利用Comparator接口复写compare方法class MyC...
2020-02-18 22:37:09
933
原创 JAVA中ArrayList的常见用法
import java.lang.reflect.Array;import java.util.*;import java.math.BigInteger;//DLRUpublic class main { public static void main(String args[]) { ArrayList<Integer>list=new ArrayList...
2020-02-18 21:05:32
323
原创 Java 字符串常用操作
import java.lang.reflect.Array;import java.util.*;import java.math.BigInteger;//DLRUpublic class main { public static void main(String args[]) { //定义 StringBuffer s=new StringBuffer();...
2020-02-18 11:52:46
157
原创 Java实现dfs模版
以走迷宫为例 0表示不可走 1表示可走 给出地图 以及始末位置 判断是否能到达import java.lang.reflect.Array;import java.util.*;public class main { public static int n,m; public static int mp[][]=new int[1000][1000]; //存储...
2020-02-03 13:19:29
1897
原创 压缩变换 蓝桥杯 java
小明最近在研究压缩算法。他知道,压缩的时候如果能够使得数值很小,就能通过熵编码得到较高的压缩比。然而,要使数值很小是一个挑战。最近,小明需要压缩一些正整数的序列,这些序列的特点是,后面出现的数字很大可能是刚出现过不久的数字。对于这种特殊的序列,小明准备对序列做一个变换来减小数字的值。变换的过程如下:从左到右枚举序列,每枚举到一个数字,如果这个数字没有出现过,刚将数字变换成它的相反数,...
2020-02-02 11:28:42
322
原创 Java中Map集合常用方法
一、添加public class main { public static void main(String[] args) { Map mp1=new HashMap(); //Object put(Object k, Object v) 向map集合中添加关联 mp1.put(1, "aaa"); mp1.put(2, "bbb"); mp1.put(3, "ccc...
2020-01-27 12:04:02
544
原创 Java中的vector类常用方法
一.添加public class main { public static void main(String[] args) { Vector v1=new Vector(); //在vector末尾添加元素 v1.add("111"); v1.add("222"); v1.add("333"); System.out.println(v1); //在指定位置添...
2020-01-27 11:10:59
631
原创 Java中Set集合的常用方法
set集合可对其中元素进行自动排序和去重TreeSet的定义 TreeSet<Integer>test=new TreeSet<Integer>();增删查 int a=7; int b=5; int c=4; //添加 test.add(a); test.add(b); test.add(c); ...
2020-01-22 17:09:34
776
1
原创 codeforces161D. Distance in Tree(树形DP)
思路:dp[i][j]表示点 i 的子节点到点 i 的距离为j的路径个数。设一点为u,其子节点为v, u、v间的边权值为w转移方程为:dp[u][j]+=dp[v][j-1];每个点对答案的贡献为:ans+=dp[u][j]*dp[v][(k-1-j)];#include <iostream>#include<cstdio>#include<c...
2019-10-08 10:24:40
138
原创 I. Misunderstood … Missing (DP)
Warm sunshine, cool wind and a fine day, while the girl watching is pursuing in chaos. Rikka reached out her hand and got the garland on her head, finding LCR with the immortal smile. The dream ended ...
2019-10-06 15:27:04
729
原创 D.Modulo Nine (DP)
思路:若要a1*a2*a3....*an能mod9等于0,则该算式中必有两个因子3相乘或者含有0。对于一个右端点r,有多个[l,r]的时候,只要最小的那个区间满足,其他肯定都满足了。这样对于一个右端点的限制条件是否满足,取决于前面出现的最后两个3出现的位置(9和0算作两个3)由此我们设dp[i][j][k]表示前i个数,最后一个因子3出现的位置为j,倒数第二个为k。由于因子中含有3的数有3、...
2019-10-06 11:28:01
290
原创 2019牛客国庆集训派对day1 -I 2019
思路:dp[i][j]表示点 i 的子节点到点 i 的距离mod 2019 = j的路径个数。设一点为u,其子节点为v,u、v间的边权值为w转移方程为:dp[u][j]+=dp[v][(j-w+2019)%2019];#include <iostream>#include<cstdio>#include<cstring>#include<a...
2019-10-05 09:53:27
428
原创 Problem J. Prime Game 2019南京站ICPC
思路:计算第i个数中包含的每个素数对答案的贡献(其贡献的区间为[i,i+1,i+2...n],则贡献为n-i+1)#include<bits/stdc++.h>#define ll long longusing namespace std; int n,a[1000010];vector<int> v[1000010]; int main(){ ...
2019-10-04 16:14:34
285
原创 Problem G. Pyramid ICPC2018 南京站
思路: 考虑到每次必须在o(1)的复杂度下计算出答案,该题肯定就是推出一个关于n的一元几次式。因此打表找规律。打表后得到1,5,15,35,70,126,210..作差 4, 10, 20, 35, 56, 84作差 6, 10, 15, 21, 28再作差 4,5,6,7再做差1,1,1,1共做差四次 因此设 f(n)=a∗n4+b∗n3+c∗n2+d∗n+e...
2019-10-04 16:02:26
545
原创 最长上升子序列(LIS)两种写法
法一:DP 复杂度O(n)#include <iostream>#include <cstdio>#include <algorithm>#include <cstdlib>#include <cstring>#include <cmath>#define ll long longusing namespa...
2019-09-22 11:13:01
161
原创 BZOJ1013 (高斯消元模版题)
#include<iostream>#include<cstring>#include<cstdio>#include<cmath>#define ll long longusing namespace std;double a[20][20],b[20],c[20][20];int n;int main(){ cin>...
2019-09-02 21:16:04
188
原创 中国剩余定理模版
#include<iostream>#include<cstdio>#define ll long longusing namespace std;//扩展欧几里得算法void gcd(ll a,ll b,ll &d,ll &x,ll &y){ if(b==0){ d=a; x=1; ...
2019-08-31 21:05:43
120
原创 扩展中国剩余定理模版
#include <cstdio>using namespace std;typedef long long ll;ll exgcd(ll a,ll b,ll &x,ll &y){ if(!b)return x=1,y=0,a; ll d=exgcd(b,a%b,x,y),z=x; x=y,y=z-a/b*y; return d...
2019-08-31 20:59:48
150
原创 2019hdu暑假多校训练赛第七场1006 Final Exam hdu6651(思维)
思路: 作为老师的话。他想让你过不了,那会拿n-k+1道题卡你。 对于学生的话。 若想在n-k+1道题目里面过一道。这n-k+1道题的分值最坏情况就是m。 所以要至少要学m+1小时。 然后对于剩下的k-1道题。 最坏的情况就是老师拿m/(n-k+1)的分数去卡你。 所以若要做对这k-1道,则学习时间是(m/(n-k+1)+1)*(k-1)。#inc...
2019-08-13 15:01:27
155
原创 欧拉函数模版
const int N=41000;long long phi[N];void euler(long long n){ for(long long i=2; i<=n; i++) phi[i]=i; for(long long i=2; i<=n; i++) if (phi[i]==i) for(long ...
2019-07-30 11:20:07
81
原创 归并排序求逆序数模版
#include <iostream>#include <iterator>#include <algorithm>#include<map>#define ll long longusing namespace std;ll a[1008611],b[1008611];ll cnt=0;void Merge(int l,int m...
2019-07-26 07:50:40
104
原创 Wave(ccpc江西省赛)
Problem DescriptionAvin is studying series. A series is called "wave" if the following conditions are satisfied:1) It contains at least two elements;2) All elements at odd positions are the same;...
2019-07-22 08:18:05
246
原创 牛客暑假多校训练第一场 E ABBA
思路: 设dp[i][j]表示有i个A,j个B的方法数。考虑递推方程: 当i<n+j时可以放A(如果A的个数i小于n或者放的’B‘的个数j小于多出来的’A’ 则可以直接放i)得到递推式: dp[i+1][j]+=dp[i][j]同理 知: j<m+i可以放B 递推式:dp[i][j+1]+=dp[i][j]#in...
2019-07-19 13:55:28
131
原创 2019年牛客多校第一场B题 Integration
思路:将进行裂项化简得: 由于则原式等于求解该式即可#include<iostream>#include<cstdio>#define ll long long#define mod 1000000007using namespace std;ll n,a[1008611],num[1008611];long long fast_mod(lon...
2019-07-19 12:35:15
142
原创 D1. Submarine in the Rybinsk Sea (easy edition)
思路:每个第k位(从1开始)都会恰好在2k和2k−1位各贡献n次#include <iostream>#include <cstring>#include <algorithm>#include <vector>#include <queue>#include <cmath>#include<strin...
2019-07-18 11:35:07
226
原创 E. Tree Painting(换根)
#include <iostream>#include <vector>#include <cstring>#define ll long longusing namespace std;vector<int> g[1008611];int v;int n,siz[1008611];ll up[1008611], sum[10086...
2019-07-03 11:51:10
501
1
原创 D. Subarray Sorting(线段树 )codeforces1187
思路:用一个队列aa存一下a数组中每一个数的位置。我们遍历数组b去找aa[b[i]].front(表示数b[i]在a第一个出现的位置),找从1到该位置的最小值是否是b[i],若不是 则为no,若是则将 改位置的数组a的数赋值成inf 以更新该区间最小值。就这样 一直找下去。。#include <iostream>#include <cstring>#inclu...
2019-07-03 11:35:18
396
2
原创 C. Vasya And Array(Codeforces1187)
思路:对于每一段连续且满足操作为1 的区间 设为相同的数,不相邻的区间之间设为递减的数。 #include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include<map>#include<cstring&...
2019-07-03 11:28:45
374
1
原创 Best Solver HDU - 5451 (共轭构造)
The so-called best problem solver can easily solve this problem, with his/her childhood sweetheart.It is known thaty=(5+26–√)1+2xy=(5+26)1+2x.For a given integerx(0≤x<232)x(0≤x<232)and ...
2019-06-25 12:32:44
177
原创 E. Polycarp and Snakes
After a hard-working week Polycarp prefers to have fun. Polycarp's favorite entertainment is drawing snakes. He takes a rectangular checkered sheet of paper of size
2019-06-24 16:52:25
269
原创 C2. Exam in BerSU (hard version)
The only difference between easy and hard versions is constraints.If you write a solution in Python, then prefer to send it in PyPy to speed up execution time.A session has begun at Beland State U...
2019-06-22 12:16:05
617
原创 MATLAB基础绘图
1.plot()plot(x,y) 对应相应的横纵坐标。plot(y) 只显示y值,x默认为x=[1,2,.....n]plot(x,y,string) x=linespace(0,2*pi,1000)表示在[0,2*pi]内描1000个点y=sin(x)plot(x,y);2.hold on hold off 让多个图同时出现结果中3.legen...
2019-05-31 17:49:25
326
原创 Matlab 变量与档案存取
1.String 字符串 s1='Example' s2='String' s3=[s1 s2]; s3输出'Example String' s4=[s1;s2];分两行输出,要求s1的长度=s2的长度 s1=='a'表示把'a'与s1中的每一个数进行比较 结果为0010000 s1(s1=='a')='z'表示把第三个赋值成'a'...
2019-05-21 18:51:39
601
原创 92. 递归实现指数型枚举
从 1~n 这 n 个整数中随机选取任意多个,输出所有可能的选择方案。输入格式输入一个整数n。输出格式每行输出一种方案。同一行内的数必须升序排列,相邻两个数用恰好1个空格隔开。对于没有选任何数的方案,输出空行。本题有自定义校验器(SPJ),各行(不同方案)之间的顺序任意。数据范围1≤n≤15输入样例:3输出样例:322 311 3...
2019-05-18 09:21:00
428
原创 Matlab 结构化程式与自定函数
1.~=不等于 if 条件 //不用加括号 动作1 else 动作22.switch 变量 case 1 动作1 case 2 动作2 otherwise 动作3 end3.while 条件 动作1end4.prod(1:n)表示n的阶乘 1e100 表示10^1005.for ...
2019-05-17 12:00:44
178
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人