- 博客(13)
- 收藏
- 关注
原创 word2vec中的CBOW模型代码实现
这里写自定义目录标题 一:模块导入 from __future__ import print_function import collections import math import numpy as np import os import random import tensorflow as tf import zipfile from matplotlib import pylab from six.moves import range from six.moves.urllib.request
2020-10-21 16:58:44
2229
1
原创 PTA 天梯赛训练 L2-005 集合相似度
给定两个整数集合,它们的相似度定义为:Nc /Nt×100%。其中Nc是两个集合都有的不相等整数的个数,Nt是两个集合一共有的不相等整数的个数。你的任务就是计算任意一对给定集合的相似度。 输入格式: 输入第一行给出一个正整数N(≤50),是集合的个数。随后N行,每行对应一个集合。每个集合首先给出一个正整数M(≤10^4 ),是集合中元素的个数;然后跟M个[0,10^9]区间内的整数。 ...
2020-04-24 12:01:42
320
原创 DP
HDU 2084 数塔 #include <iostream> #include <cstring> #include <algorithm> using namespace std; int d[1001][1001],a[1001][1001]; int n; int solve(int i,int j) { if(d[i][j]>=0) re...
2020-02-12 11:17:48
120
原创 快速幂
long long ksm(long long a,long long b) { int ans = 1,base = a; while(b != 0){ if(b & 1 != 0){ ans *= base; } base *= base; b >>= 1; } ...
2019-11-05 21:22:43
106
原创 概率DP
HDU 4576 https://www.cnblogs.com/kevinACMer/p/3723531.html #include <stdio.h> #include <string.h> #include #include double dp[205][2]; int main() { int n,m,l,r; while(scanf("%d%d%d%d",&a...
2019-09-16 11:23:11
80
原创 KMP
HDU 5510 #include <stdio.h> #include #include <string.h> #include const int maxn=1e4+5; using namespace std; int num[maxn]; string str[maxn]; void get_next(string s) { memset(num,0,sizeo...
2019-09-16 10:33:30
177
原创 N皇后问题
HDU 2553 #include #include <bits/stdc++.h> using namespace std; const int maxn=11; int mp[maxn]; int ans,n; void dfs(int x,int m) { if(x>m) { ans++; } for(int i=1; i<=m; i++) { mp[x]=i; i...
2019-09-11 17:07:10
71
原创 棋盘问题
POJ1321 #include #include <string.h> using namespace std; int vis[20]; char mp[20][20]; int ans,n,k; int dfs(int x,int y) { if(y>=k) { ans++; return 0; } for(int i=x;i<n;i++) for(int j=0;...
2019-09-11 17:01:52
88
原创 迷宫问题
POJ3984 #include using namespace std; int a[6][6],vis[7][7],road[7][7]; int d[2][4]={0,1,-1,0,1,0,0,-1}; void dfs(int i,int j) { vis[i][j]=1; if(i5&&j5) { road[i][j]=1; return; } for(int k=0;...
2019-09-11 17:00:33
86
原创 poj3461 KMP&哈希
KMP: #include<stdio.h> char A[1000005],B[10005]; int next[10005]; void getnext() { int i,j; next[0]=0; for(i=1,j=0;B[i];i++) { while(j>0&&B[i]!=B[j]) j=next[j-1]; if(B[i]==B[j]) j++; ...
2019-08-29 17:16:40
93
原创 最小生成树:prim+kruskal
Kruskal:HDU 1879 继续畅通工程 #include #include #include #include <stdio.h> using namespace std; const int maxn=100005; int p[maxn],sum,cnt; struct node { int x,y,z,f; }a[maxn]; bool cmp(node a,nod...
2019-08-26 17:37:51
132
原创 最短路:floyd+dijkstra
#include #include using namespace std; const int INF=0x3f3f3f3f; const int N=100005; int p[N],q[N]; int main() { int n,m; int f[110][110]; while(cin>>n>>m&&n&&m) { int i,...
2019-08-26 09:57:11
129
原创 拓扑排序
并查集:HDU 1879 继续畅通工程 int find(int x) { if(p[x]==x) return x; else return p[x]=find(p[x]); } int kruskal() { for(int i=1;i<=cnt;i++) p[i]=i; sort(a+1,a+cnt+1,cmp); for(int i=1;i<=cnt;i++) { int xx...
2019-08-26 09:53:56
88
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人