Chri_K

10 2020 档案

常用cmath函数
摘要:#include <math.h> double ceil( double num ); double floor( double arg ); ceil函数返回不小于num的最小整数,如num = 6.04, 则返回7.0 floor函数返回不大于num的最大的数,如num = 6.04, 则返回 阅读全文

posted @ 2020-10-31 13:31 Chri_K 阅读(188) 评论(0) 推荐(0)

对数运算
摘要: 阅读全文

posted @ 2020-10-31 13:24 Chri_K 阅读(138) 评论(0) 推荐(0)

快读
摘要:int read() { int a=0,x=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')x=-1;ch=getchar();} while(ch>='0'&&ch<='9'){a=a*10+ch-'0';ch=getchar();} 阅读全文

posted @ 2020-10-31 10:16 Chri_K 阅读(57) 评论(0) 推荐(0)

树状数组
摘要:树状数组单点修改区间查询 #include<iostream> using namespace std; int n,m; int tree[2000020]; int lowbit(int x) { return x&(-x); } void update(int x,int v) { while 阅读全文

posted @ 2020-10-30 12:00 Chri_K 阅读(49) 评论(0) 推荐(0)

构造(排列组合 插板法)
摘要:#include <iostream> #include <cstdio> #include <cmath> #include <cstring> using namespace std; typedef long long ll; const int maxn = 1000000; const i 阅读全文

posted @ 2020-10-29 14:50 Chri_K 阅读(175) 评论(0) 推荐(0)

字符串(string)(字符串相加)
摘要:#include<iostream> #include<cstring> using namespace std; int main() { int t; cin>>t; string a,b; while(t--) { cin>>a>>b; if(a+b>b+a) { cout<<">"<<end 阅读全文

posted @ 2020-10-29 13:13 Chri_K 阅读(145) 评论(0) 推荐(0)

tarjan1
摘要:#include<iostream> #include<cstring> using namespace std; struct node { int v; int next; }edge[1010]; int dfn[1010],low[1010],heads[1010]; int cnt,vis 阅读全文

posted @ 2020-10-28 13:47 Chri_K 阅读(52) 评论(0) 推荐(0)

魔术棋子(记忆化搜索)
摘要:#include<iostream> using namespace std; int n,m,k,ans; int map[110][110]; int vis[110][110][110]; int main() { cin>>n>>m>>k; for(int i=1;i<=n;i++) { f 阅读全文

posted @ 2020-10-27 17:49 Chri_K 阅读(111) 评论(0) 推荐(0)

日期(csp2019)
摘要:#include <iostream> using namespace std; int a,c; char b; int ans; int main() { cin>>a>>b>>c; if(a>12||a==0) { ans++; } if(a>12||a==0) { if(c>31) { an 阅读全文

posted @ 2020-10-27 11:35 Chri_K 阅读(123) 评论(0) 推荐(0)

神奇的数字(magic)
摘要:#include <iostream> #include<cstring> using namespace std; int dp[1000050]; int main() { memset(dp,0x3f3f,sizeof dp); dp[1] = 1; int n; cin>>n; while( 阅读全文

posted @ 2020-10-27 11:04 Chri_K 阅读(111) 评论(0) 推荐(0)

最佳调度问题(dfs)
摘要:#include<iostream> #include<algorithm> using namespace std; bool cmp(int x,int y) { return x>y; } int ans=2147483647,n,k; int t[1010],s[1010]; void df 阅读全文

posted @ 2020-10-25 22:41 Chri_K 阅读(147) 评论(0) 推荐(0)

最大连续和(贪心)
摘要:#include<iostream> using namespace std; int a[50010],dp[50050]; int ans=-2147483647; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; dp 阅读全文

posted @ 2020-10-24 14:30 Chri_K 阅读(57) 评论(0) 推荐(0)

字符序列(模拟)
摘要:#include<iostream> using namespace std; int n,sum=0; int ans[15]; bool judge() { int cnt=0; for(int i=3; i<=n; i++) { if(ans[i]==ans[i-2]) { cnt++; } 阅读全文

posted @ 2020-10-24 14:11 Chri_K 阅读(109) 评论(0) 推荐(0)

装载问题(load)
摘要:这题好像就是个01背包啊。。。 #include<iostream> using namespace std; int w; int dp[60]; int main() { int n,c; cin>>n>>c; int sum=0; for(int i=1;i<=n;i++) { cin>>w; 阅读全文

posted @ 2020-10-24 13:31 Chri_K 阅读(103) 评论(0) 推荐(0)

进制转换(noip2000)
摘要:#include<iostream> #include<cstdio> #include<cmath> #include<cstring> using namespace std; void change(int n,int r) { if(n==0) { return; } int m=n%r; 阅读全文

posted @ 2020-10-22 16:39 Chri_K 阅读(108) 评论(0) 推荐(0)

自然数的拆分(dfs)
摘要:#include<iostream> using namespace std; int a[100],n,m; void dfs(int dep,int pre,int sum) { if(sum==n) { for(int i=1; i<=dep-1; i++) { cout<<a[i]; if( 阅读全文

posted @ 2020-10-22 16:30 Chri_K 阅读(153) 评论(0) 推荐(0)

训练(training)
摘要:50分代码(无能为力) 优先队列 #include<iostream> #include<queue> #define val first #define high second using namespace std; const int M = 1000000; int n,m; priorit 阅读全文

posted @ 2020-10-22 14:10 Chri_K 阅读(390) 评论(0) 推荐(0)

P1325 雷达安装 (贪心)
摘要:#include<iostream> #include<algorithm> #include<cmath> using namespace std; struct node { double l; double r; }a[1010]; bool cmp(node x,node y) { retu 阅读全文

posted @ 2020-10-21 13:20 Chri_K 阅读(116) 评论(0) 推荐(0)

智力大冲浪(贪心)
摘要:#include<iostream> #include<algorithm> using namespace std; struct node { int tl; int km; }a[510]; bool cmp(node x,node y) { return x.km>y.km; } int t 阅读全文

posted @ 2020-10-21 10:57 Chri_K 阅读(96) 评论(0) 推荐(0)

堆积木(贪心)
摘要:#include<iostream> #include <algorithm> using namespace std; struct node { int w; int f; int s; }p[50010]; bool cmp(node x,node y) { return x.s < y.s; 阅读全文

posted @ 2020-10-19 22:45 Chri_K 阅读(131) 评论(0) 推荐(0)

奶酪工厂
摘要:#include <iostream> using namespace std; struct node { int cost; int need; }p[10010]; int main() { int n,s; cin>>n>>s; for (int i=1;i<=n;i++) { cin>>p 阅读全文

posted @ 2020-10-19 16:40 Chri_K 阅读(63) 评论(0) 推荐(0)

P1080 国王游戏(非高精版)
摘要:#include <iostream> #include <algorithm> using namespace std; struct node { int l; int r; int w; }p[1010]; bool cmp(node x,node y) { return x.w < y.w; 阅读全文

posted @ 2020-10-19 15:34 Chri_K 阅读(1917) 评论(0) 推荐(0)

P1106 删数问题
摘要:#include <iostream> #include <cstring> using namespace std; char a[260]; int main() { int len,k; cin>>a; cin>>k; len=strlen(a); while(k--) { for(int i 阅读全文

posted @ 2020-10-19 11:26 Chri_K 阅读(101) 评论(0) 推荐(0)

P1209 [USACO1.3]修理牛棚 Barn Repair
摘要:#include<iostream> #include<algorithm> using namespace std; int a[210]; int wst[210]; bool cmp(int a,int b) { return a>b; } int main() { int m,s,c; ci 阅读全文

posted @ 2020-10-19 10:38 Chri_K 阅读(91) 评论(0) 推荐(0)

网络(network)
摘要:#include<iostream> using namespace std; const int max_M = 5000005; const int max_N = 500005; int n, m, X[max_M],Y[max_M], P[max_N], preX[max_M], preY[ 阅读全文

posted @ 2020-10-17 23:19 Chri_K 阅读(520) 评论(0) 推荐(0)

染色(colour)
摘要:#include<iostream> using namespace std; int main() { int n; cin>>n; if(n<=6) { cout<<(n+1)/2<<endl; for(int i=1;i<=n;i++) { cout<<(1+i)/2<<" "; } } el 阅读全文

posted @ 2020-10-17 16:13 Chri_K 阅读(183) 评论(0) 推荐(0)

第k小(二分)
摘要:#include<iostream> using namespace std; #define N 90000 #define ll long long #define inf 1000000000 ll s[N],t[N]; int n,k; bool check(ll x) { int tp = 阅读全文

posted @ 2020-10-17 12:25 Chri_K 阅读(86) 评论(0) 推荐(0)

购物(money)
摘要:#include<iostream> #include<iomanip> using namespace std; int main() { int n; cin>>n; int x,y; double sum=0; for(int i=1;i<=n;i++) { cin>>x>>y; sum=su 阅读全文

posted @ 2020-10-17 09:50 Chri_K 阅读(58) 评论(0) 推荐(0)

哈密顿路(dfs)
摘要:#include<iostream> #include<cstring> using namespace std; int a[101][101],n,flag,num; int b[101],d[101]; void print() { flag=1; for(int i=1;i<=n;i++) 阅读全文

posted @ 2020-10-15 16:34 Chri_K 阅读(89) 评论(0) 推荐(0)

犯罪团伙(并查集)
摘要:#include<iostream> using namespace std; int a[1010]; int x,y; int temp; int main() { int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { a[i]=i; } for(int i=1 阅读全文

posted @ 2020-10-15 15:51 Chri_K 阅读(76) 评论(0) 推荐(0)

运输(贪心)
摘要:#include<iostream> #include<algorithm> using namespace std; bool cmp(int a,int b) { return a>b; } int w[10010]; int main() { int n,k; cin>>n>>k; for(i 阅读全文

posted @ 2020-10-15 12:25 Chri_K 阅读(98) 评论(0) 推荐(0)

整数区间(贪心)
摘要:#include<iostream> #include<algorithm> using namespace std; struct node { int l; int r; }a[10010]; bool cmp(node x,node y) { if(x.l==y.l) { return x.r 阅读全文

posted @ 2020-10-15 11:39 Chri_K 阅读(79) 评论(0) 推荐(0)

营养膳食(贪心)
摘要:#include<iostream> #include<algorithm> using namespace std; struct food { int a; int b; }f[210]; bool cmp(food x,food y) { return x.a>y.a; } int kind[ 阅读全文

posted @ 2020-10-15 10:49 Chri_K 阅读(138) 评论(0) 推荐(0)

零件分组(stick)
摘要:#include<iostream> #include<algorithm> using namespace std; struct node { int l,w; }a[1010]; int t[1010]; bool cmp(node x,node y) { if(x.l==y.l) retur 阅读全文

posted @ 2020-10-13 16:58 Chri_K 阅读(359) 评论(0) 推荐(0)

活动选择act0
摘要:#include<iostream> #include<algorithm> using namespace std; int b[1010],e[1010]; int t,temp; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>> 阅读全文

posted @ 2020-10-13 15:47 Chri_K 阅读(83) 评论(0) 推荐(0)

美元汇率dollars
摘要://思路:用最少的美元换最多的马克,再用最少的马克换最多的美元 即:寻找当第i天的数大于第i+1天时,就将美元换成马克再换回美元(sum=sum*a[i]/a[i+1]) #include<iostream> #include<iomanip> using namespace std; int a[ 阅读全文

posted @ 2020-10-13 15:19 Chri_K 阅读(156) 评论(0) 推荐(0)

数列分段divide
摘要://这题好像不贪心啊+_+ #include<iostream> using namespace std; int a; int main() { int n,m; cin>>n>>m; int ans=0; int sum=0; for(int i=1;i<=n;i++) { cin>>a; if 阅读全文

posted @ 2020-10-13 14:33 Chri_K 阅读(93) 评论(0) 推荐(0)

精度计算(保留几位小数)
摘要:1.需要头文件 #include <iomanip> 2. 要保留两位有效小数 cout<<setiosflags(ios::fixed)<<setprecision(2)<< 然后再输出实数类型变量即可以保留2位小数输出了,当然你要保留三位小数,setprecision(3)就行。 setprec 阅读全文

posted @ 2020-10-10 10:18 Chri_K 阅读(828) 评论(0) 推荐(0)

洛谷P1119灾后重建
摘要:#include<iostream> using namespace std; #define N 205 int n,m; int a[N]; int f[N][N]; inline void updata(int k) { for(int i=0;i<n;i++) { for(int j=0;j 阅读全文

posted @ 2020-10-08 11:20 Chri_K 阅读(101) 评论(0) 推荐(0)

暴雨rain
摘要:#include<cstdio> #include<cstring> #include<algorithm> #include<cassert> #include<queue> #include<vector> #include<map> #include<cmath> #include<set> 阅读全文

posted @ 2020-10-06 15:09 Chri_K 阅读(172) 评论(0) 推荐(0)

石子游戏stone
摘要:#include<iostream> using namespace std; int main() { int t,N;//t为几组,N为几堆 cin>>t; while(t--) { int win=0; //更新 cin>>N; int n,m;//m为每堆数量,n为每堆可取的最大数量 whi 阅读全文

posted @ 2020-10-05 15:48 Chri_K 阅读(92) 评论(0) 推荐(0)

化学家chemist
摘要:#include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int MAXN=300010; int n,m,a[MAXN],b[MAXN],p[MAXN],v[MAXN]; int 阅读全文

posted @ 2020-10-04 15:05 Chri_K 阅读(381) 评论(0) 推荐(0)

卢斯进制(NOIP1998进制位)emm~
摘要://我的80分代码=_=(de不出来)(好像是"ERROR”的问题) #include<iostream>#include <cstring>#include<algorithm>#include <cstdio>using namespace std;char tmp[1000];char str 阅读全文

posted @ 2020-10-01 16:17 Chri_K 阅读(205) 评论(0) 推荐(0)