博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一月流水账
阅读量:5126 次
发布时间:2019-06-13

本文共 13027 字,大约阅读时间需要 43 分钟。

咸鱼好久了阿www

1.20

补cf392 还是好菜喔wuwuwuw

B.

比赛的时候...想去暴力,觉得写起来会很繁,然后又想有没有简单的做法

然后又没反应过来,又想暴力..又觉得繁...对!就这样...最后20min开始写暴力

挂了..GG

每个颜色都会出现一次,而且每4个肯定又会出现,按mod4记录该哪个字母

1 #include 
2 #include
3 #include
4 #include
5 #include
6 using namespace std; 7 8 char s[105]; 9 10 void solve(){11 int n = strlen(s);12 map
cnt;13 map
h;14 for(int i = 0;i < n;i++){15 if(s[i] == '!') continue;16 h[i%4] = s[i];17 }18 for(int i = 0;i < n;i++){19 if(s[i] == '!'){20 cnt[h[i%4]]++;21 }22 }23 printf("%d %d %d %d\n",cnt['R'],cnt['B'],cnt['Y'],cnt['G']);24 }25 26 int main(){27 while(scanf("%s",s) != EOF){28 solve();29 }30 return 0;31 }
View Code

 

C.

感觉C更简单些..模拟最后一个周期

n = 1的时候特判一下

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 7 typedef long long LL; 8 LL k,c[105][105]; 9 int n,m,x,y;10 11 void solve(){12 LL T,tot,cnt,cc;13 if(n == 1){14 LL u = k/m;15 k = k%m;16 LL cc = 0LL;17 for(int i = 1;i <= m;i++) c[1][i] = u;18 for(int i = 1;i <= m;i++){19 if(cc == k) break;20 c[1][i]++;21 cc++;22 }23 }24 else{25 T = 2LL*m*(n-1);26 tot = k/T;27 cnt = k % T;28 cc = 0LL;29 memset(c,0,sizeof(c));30 int flag = 0;31 for(int i = 1;i <= n;i++){32 if(cc == cnt){33 flag = 1;34 break;35 }36 for(int j = 1;j <= m;j++){37 c[i][j]++;38 cc++;39 if(cc == cnt){40 flag = 1;41 break;42 }43 }44 if(flag == 1) break;45 }46 47 for(int i = n-1;i >= 2;i--){48 if(cc == cnt){49 flag = 1;50 break;51 }52 for(int j = 1;j <= m;j++){53 c[i][j]++;54 cc++;55 if(cc == cnt){56 flag = 1;57 break;58 }59 }60 if(flag == 1) break;61 }62 63 for(int i = 1;i <= n;i++){64 for(int j = 1;j <= m;j++){65 if(i == 1 || i == n){66 c[i][j] += tot;67 }68 else{69 c[i][j] += 2LL*tot;70 }71 }72 }73 }74 75 LL mx = 0LL;76 LL mn = 1e18+7;77 for(int i = 1;i <= n;i++){78 for(int j = 1;j <= m;j++){79 mx = max(mx,c[i][j]);80 mn = min(mn,c[i][j]);81 }82 }83 printf("%I64d %I64d %I64d\n",mx,mn,c[x][y]);84 85 }86 87 int main(){88 while(scanf("%d %d %I64d %d %d",&n,&m,&k,&x,&y) != EOF){89 solve();90 }91 return 0;92 }
View Code

D.

贪心做的..群里dalao说的dp的做法

下午写的时候也磨叽了好久..感觉0的时候不好写

每次写这样带个while...啥时候跳出循环,边界总是搞不清楚

不断死循环....

1 #include 
2 #include
3 #include
4 #include
5 #include
6 using namespace std; 7 8 typedef long long LL; 9 int n;10 char s[105];11 LL p[62];12 13 void solve(){14 int len = strlen(s+1);15 int cnt = 0;16 LL base = 1LL;17 LL ans = 0LL;18 for(int i = len;i >= 1;){19 int j = i;20 LL now = s[j]-'0';21 while(j > 1 && (i-j) < 18 && now + (s[j-1]-'0')*p[i-(j-1)] < n ){22 j--;23 now = now + (s[j]-'0')*p[i-j];24 //printf("------- j = %d now = %d\n",j,now);25 }26 cnt++;27 28 while(j < i && s[j] == '0') j++;29 // printf("==== j = %d \n",j);30 i = j-1;31 ans = ans + now*base;32 33 //printf("i = %d j = %d now = %I64d ",i,j,now);34 //printf("base = %I64d ans = %I64d \n",base,ans);35 base = base*n;36 //while(j < i )37 }38 printf("%I64d\n",ans);39 }40 41 int main(){42 p[0] = 1LL;43 for(int i = 1;i <= 61;i++) p[i] = p[i-1]*10LL;44 while(scanf("%d",&n) != EOF){45 scanf("%s",s+1);46 solve();47 }48 return 0;49 }
View Code

 

然后瞅了会儿Kaggle的入门教程...抄别人代码一直报错

环境没有搞好

1.21

手写数字的识别

搞python

先装好pip ,装这个好像没踩坑.

然后就是 装一些库

踩坑有

.虽然电脑是64位的,但是装的Python是32位的

.pip install xxxxxxxx的时候 需要进入到Script 这个目录下面装才行

.装的Python的版本是2.7的...版本下错一次..一把老泪

这些库的下载地址

然后网上抄了好多代码..都运行是 Memory error

一脸懵逼..后来抄了个终于好了

现在还没有看原理...

算 第一个 "Hello World" 吗wwwww

 

 

F.

把公比写成这样d = x/y gcd(x,y) = 1

然后 n l r 都很小

假设序列都是单调递增的

算贡献 是首项末项都在[l,r]区间里面的

就是末项在[1,r]的 - 减去首项在[1,l-1] 的

具体的式子 根据这个 an = a1*(x/y)^(n-1)解下不等式

View Code

 

1.22

牛顿方法

1.23

看到matlab的数值计算,想到要大一的时候会就可以少积点分了

但一想平时好好算考那么点了,要matlab不更GG了..><

网易的视频虽然有字幕但是没有作业

于是又到coursera上从头看了..

发现打个素数筛也要瞅板子

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 7 const int maxn = 1e6+5; 8 int is[maxn],n; 9 10 void Pre(){11 memset(is,0,sizeof(is));12 is[1] = is[0] = 1;13 for(int i = 2;i < maxn;i++){14 if(is[i] == 0)15 for(int j = i*2;j < maxn;j+=i)16 is[j] = 1;17 }18 }19 20 void solve(){21 for(int i = 1;i <= 3000;i++){22 if(is[i*n+1]){23 printf("%d\n",i);24 return;25 }26 }27 28 }29 30 int main(){31 Pre();32 while(scanf("%d",&n) != EOF){33 solve();34 }35 return 0;
View Code

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 7 int n,m; 8 string a[1005],b[1005]; 9 10 void solve(){11 int l = n,r = m,cnt = 0;12 for(int i = 1;i <= n;i++){13 for(int j = 1;j <= m;j++){14 if(a[i] == b[j]){15 cnt++;16 break;17 }18 }19 }20 l -= cnt;r -= cnt;21 if(cnt%2) l++;22 if(l > r) puts("YES");23 else puts("NO");24 }25 26 int main(){27 while(scanf("%d %d",&n,&m) != EOF){28 for(int i = 1;i <= n;i++) cin >> a[i];29 for(int i = 1;i <= m;i++) cin >> b[i];30 solve();31 }32 return 0;33 }
View Code

这题EOF不行

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 7 const int maxn = 1e5+5; 8 int fa[maxn],p[maxn],n; 9 int Find(int x){10 return x == fa[x]?x:fa[x] = Find(fa[x]);11 }12 13 void solve(){14 for(int i = 1;i <= n;i++){15 int u = p[i];16 int v = i;17 int x = Find(u);18 int y = Find(v);19 if(x != y) fa[x] = fa[y];20 }21 int cnt = 0;22 for(int i = 1;i <= n;i++){23 //printf("fa[%d] = %d\n",i,fa[i]);24 if(fa[i] == i) cnt++;25 }26 printf("%d\n",cnt);27 }28 29 int main(){30 scanf("%d",&n);31 for(int i = 1;i <= n;i++){32 scanf("%d",&p[i]);33 fa[i] = i;34 }35 solve();36 return 0;37 }
View Code

要考虑到k > n/2 的时候

这个时候,可以看成k = n-k

还有 n/2 当 n 为奇的时候,是向下取整的

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 7 const int maxn = 1e6+5; 8 typedef long long LL; 9 LL c[maxn];10 int n,k;11 12 int lowbit(int x){
return x & (-x);}13 14 LL sum(int x){15 LL ret = 0LL;16 while(x > 0){17 ret += c[x];x -= lowbit(x);18 }19 return ret;20 }21 22 void update(int x,int d){23 while(x < maxn){24 c[x] += 1LL*d;x += lowbit(x);25 }26 }27 28 void solve(){29 LL ans = 1LL;30 int l = 1,r;31 int T = n/2;32 //if(n%2) T++;33 if(k > T) k = n-k;34 for(int j = 1;j <= n;j++){35 if(l+k > n){36 r = l+k-n;37 LL tmp = sum(n) - sum(l) + sum(r-1);38 int u = sum(n) - sum(l);39 int v = sum(r-1);40 //printf("l = %d r = %d u = %d v = %d\n",l,r,u,v);41 ans = ans + tmp + 1LL;42 }43 else{44 r = l+k;45 //printf("--- l = %d r = %d\n",l,r);46 int tmp = sum(r-1) - sum(l);47 ans = ans + tmp + 1LL;48 }49 update(l,1);50 update(r,1);51 printf("%I64d",ans);52 //if(j == 3) break;53 if(j == n) printf("\n");54 else printf(" ");55 l = r;56 }57 }58 59 int main(){60 while(scanf("%d %d",&n,&k) != EOF){61 memset(c,0,sizeof(c));62 solve();63 }64 return 0;65 }
View Code

 

1.24

监督学习和非监督学习

每逢回家必犯病,不如滚去北方吸口霾(....

1.25

想到的点就是分成两个部分来构造,而且是左边一个完全图分量,右边一个完全图分量,中间连一条边当桥

可是度数凑不对

证明偶数k构造不出,连通图的总度数和为偶数

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 using namespace std; 8 9 const int maxn = 1e6+5;10 int k;11 int d[1005];12 int vis[maxn];13 14 void solve(){15 if(k%2 == 0){16 puts("NO");17 return;18 }19 puts("YES");20 if(k == 1){21 printf("2 1\n1 2\n");22 return;23 }24 vector
> ans;25 memset(d,0,sizeof(d));26 memset(vis,0,sizeof(vis));27 for(int i = 2;i <= k;i++) ans.push_back(make_pair(1,i));28 for(int i = 2;i <= k;i++){29 ans.push_back(make_pair(i,k+1));30 ans.push_back(make_pair(i,k+2));31 for(int j = i+1;j <= k;j++){32 if(j-i == 1 && !vis[j] && !vis[i]){33 vis[i] = vis[j] = 1;34 continue;35 }36 ans.push_back(make_pair(i,j));37 }38 }39 ans.push_back(make_pair(k+1,k+2));40 41 ans.push_back(make_pair(1,k+3));42 for(int i = k+4;i <= 2*k+2;i++) ans.push_back(make_pair(k+3,i));43 44 for(int i = k+4;i <= 2*k+2;i++){45 ans.push_back(make_pair(i,2*k+3));46 ans.push_back(make_pair(i,2*k+4));47 for(int j = i+1;j <= 2*k+2;j++){48 if(j-i == 1 && !vis[i] && !vis[j]){49 vis[i] = vis[j] = 1;50 continue;51 }52 //printf(" i = %d j = %d\n",i,j);53 ans.push_back(make_pair(i,j));54 }55 }56 ans.push_back(make_pair(2*k+3,2*k+4));57 printf("%d %d\n",2*k+4,ans.size());58 for(int i = 0;i < ans.size();i++) {59 printf("%d %d\n",ans[i].first,ans[i].second);60 d[ans[i].first]++;61 d[ans[i].second]++;62 }63 //for(int i = 1;i <= 2*k+4;i++) printf("d[%d] = %d\n",i,d[i]);64 }65 66 int main(){67 while(scanf("%d",&k) != EOF){68 solve();69 }70 return 0;71 }
View Code

 

Model and Cost Function

看得不是很明白...

spoj  卡特兰数

1.26

我爱劳动www

1.27

看完第一周辣>w<

1.28

Suppose m=4m=4 students have taken some class, and the class had a midterm exam and a final exam. You have collected a dataset of their scores on the two exams, which is as follows:midterm (midterm)^2   final89        7921        9672        5184        7494        8836        8769        4761        78You'd like to use polynomial regression to predict a student's final exam score from their midterm exam score. Concretely, suppose you want to fit a model of the form hθ(x)=θ0+θ1x1+θ2x2hθ(x)=θ0+θ1x1+θ2x2, where x1x1 is the midterm score and x2x2 is (midterm score)^2. Further, you plan to use both feature scaling (dividing by the "max-min", or range, of a feature) and mean normalization.What is the normalized feature x(4)2x2(4)? (Hint: midterm = 89, final = 96 is training example 1.) Please enter your answer in the text box below. If applicable, please provide at least two digits after the decimal place.
View Code

 

1.29

看完第二周辣>w<然鹅还是什么都不会的柑橘

1.30

第三周ing

激动地YY出E的做法...兴高采烈地敲半天发现过不了样例一阵printf调试发现方法就不对= =

YY的出来就对了那么一点点(l,r)对 l加,对r+1 减 = =

先按照区间的长短排序

如果当前的倍数是 d ,并且纪念品区间长度大于 d ,这个纪念品一定是能够买的

这个的(m/1 + m/2 + m/3 +... +m/m)的复杂度是 mlogm的

每次询问的答案就是 d 的倍数的纪念品加在一起,再加上区间长度大于d的(容斥,n - 区间长度小于d的)

1 #include 
2 #include
3 #include
4 #include
5 #include
6 using namespace std; 7 8 const int maxn = 3e5+5; 9 int n,m,l[maxn],r[maxn];10 vector
> g[maxn];11 int c[maxn];12 13 int lowbit(int x){ return x & (-x);}14 15 int update(int x,int v){16 while(x < maxn){17 c[x] += v;18 x += lowbit(x);19 }20 }21 22 int query(int x){23 int res = 0;24 while(x){25 res += c[x];26 x -= lowbit(x);27 }28 return res;29 }30 31 void solve(){32 int les = 0;33 for(int i = 1;i <= m;i++){34 int ans = 0;35 for(int j = i;j <= m;j+=i){36 ans += query(j);37 }38 for(int j = 0;j < g[i].size();j++){39 int u = g[i][j].first;40 int v = g[i][j].second;41 update(u,1);42 update(v+1,-1);43 }44 //printf("i = %d ans = %d les = %d\n",i,ans,les);45 printf("%d\n",ans+n-les);46 les += g[i].size();47 }48 }49 50 int main(){51 while(scanf("%d %d",&n,&m) != EOF){52 for(int i = 0;i <= n;i++) g[i].clear();53 memset(c,0,sizeof(c));54 for(int i = 1;i <= n;i++){55 scanf("%d %d",&l[i],&r[i]);56 g[r[i]-l[i]+1].push_back(make_pair(l[i],r[i]));57 }58 solve();59 }60 return 0;61 }
View Code

 

1.31

忘了在干嘛了

 

转载于:https://www.cnblogs.com/wuyuewoniu/p/6337644.html

你可能感兴趣的文章
关于CefSharp的坎坷之路
查看>>
ubuntu文件乱码
查看>>
bash学习:登陆、非登陆shell,交互、非交互shell,以及它们的startup文件
查看>>
[题目] JavaScript 练习题目(二) [20-40]
查看>>
SpringBoot非官方教程 | 第六篇:springboot整合mybatis
查看>>
alibaba之Nacos
查看>>
实现memcpy函数
查看>>
Vue 中使用 jQuery
查看>>
数据采集为什么要用IP代理?
查看>>
Dynamics 365中的事件框架与事件执行管道(Event execution pipeline)
查看>>
Errors occurred during the build. Errors running builder 'JavaScript Validator'
查看>>
jquery自定义对话框alert、confirm和prompt
查看>>
intellijj idea正则替换下划线为驼峰
查看>>
《漫画线性代数》读书笔记 用矩阵解方程组
查看>>
关于flume的几道题
查看>>
Java Spring学习笔记 01.@Autowired与@Resource区别?
查看>>
python 小试牛刀之信息管理
查看>>
PHPStorm配置自己喜欢的主题
查看>>
小程序爬坑记录-wxml
查看>>
windows服务与控制台应用程序之HttpWebResponse的使用
查看>>