裸的LIS ----------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #define rep( i , n ) for( int i = 0 ; i < n ; ++i ) #define clr( x , c ) memset…
#include<cstdio> #include<algorithm> using namespace std; int n,a[5001],b[5001],en; int main() { scanf("%d",&n); for(int i=1;i<=n;++i) scanf("%d",&a[i]); for(int i=1;i<=n;++i) { int *p=lower_bound(b+1,b+en+1,a…
最长上升子序列.虽然数据可以直接n方但是另写了个nlogn的 转移:f[i]=max(f[j]+1)(a[j]<a[i]) O(n^2) #include<iostream> #include<cstdio> using namespace std; const int N=5005; int n,a[N],f[N],ans; int read() { int r=0,f=1; char p=getchar(); while(p>'9'||p<'0') { if(…
Power Hungry Cows Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5522 Accepted: 1384 Description FJ's cows would like to be able to compute integer powers P (1 <= P <= 20,000) of numbers very quickly, but need your help. Because they…
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1670 用叉积判断.注意两端的平行于 y 轴的. #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define ll long long #define db double using namespace std; ,INF=1e7; int n,sta[N]…
c[x][y]为从(x,y)到(n,m)的最大值,记忆化一下 有个剪枝是因为y只能+1所以当n-x>m-y时就算x也一直+1也是走不到(n,m)的,直接返回0即可 #include<iostream> #include<cstdio> using namespace std; const int N=105,dx[]={-1,0,1}; int n,m,a[N][N],c[N][N]; int read() { int r=0,f=1; char p=getchar(); w…
本来以为是一道数学题,一顿XJBT导式子,结果就是个幼儿园都会的模拟. Code: #include<bits/stdc++.h> #define ll long long using namespace std; int main(){ ll n; scanf("%lld",&n); int ans=0; for(;n>1;++ans){ if(n%2==0) n>>=1; else n=n*3+1; } printf("%d"…