- 博客(71)
- 收藏
- 关注
原创 实验四
最长公共子序列#include<iostream>#include<string>#include<cmath>using namespace std;string a,b;int dp[210][210];int main(){ cin>>a>>b; int sa=a.size(),sb=b.size(); fo...
2018-10-26 00:02:08
218
原创 学习笔记3
#一个简单的程序import tensorflow as tf#定义网络结构和前向传播算法def get_weight(shape): w=tf.Variable() return wdef get_bias(shape): b=tf.Variable() return bdef forward(x,shape): w1=get_weight(...
2018-10-17 22:39:47
222
原创 学习笔记2
import tensorflow as tf#常量tf.constant(value,dtype,shape,name)#变量tf.Variable(self,dtype)#随机数生成函数#正态分布随机数tf.random_normal([2,3],stddev=2,mean=0,seed=1)#截断正态分布随机数(超过两个标准差就截断)tf.truncated_norma...
2018-10-17 22:39:12
183
原创 学习笔记1
#使用的模块import tensorflow as tfimport numpy as np#计算图tf.get_default_graph()#获取当前默认的计算图a.graph()#查看张量所属的计算图g1=tf.Graph()#生成新的计算图with g1.as_default():#把g1设置为默认计算图with tf.Session(graph=g1) as ses...
2018-10-17 22:38:07
164
原创 实验三
电子老鼠闯迷宫#include<iostream>#include<queue>using namespace std;char map[15][15];int sx,sy,ex,ey;int INF=500;int d[15][15];int dx[4]={0,1,0,-1};int dy[4]={-1,0,1,0};struct point{...
2018-10-10 17:19:30
224
原创 实验二
八皇后问题#include<iostream>using namespace std;int a[10][10],Count=0; void make(int m);int main(){ make(0); return 0;} void make(int m){//已经填了几行 //cout<<m<<endl; if(m==8){...
2018-09-28 10:13:20
166
原创 实验一
二分查找#include<iostream>using namespace std;int a[10000+10];bool BinarySearch(int s,int e,int v);int main(){ int n,m,v; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } cin&...
2018-09-21 07:11:39
157
原创 POJ 3263 Tallest Cow
题目:n只奶牛,第i只身高最高为h,已知r组数据,每组数据有两个整数ai,bi表示这两个编号的奶牛互相可以看到,即他们之间的奶牛的身高都严格小于他们俩输入n,i,h,r和r组ai,bi,输出每只奶牛的最大可能身高(1 ≤ N ≤ 10,000)(0 ≤ R ≤ 10,000)(1 ≤ H ≤ 1,000,000)(1 ≤ A, B ≤ N)分析:所有的奶牛...
2018-06-26 00:00:38
231
原创 BZOJ 1218 激光炸弹
题目:一种新型的激光炸弹,可以摧毁一个边长为R的正方形内的所有的目标。现在地图上有n(N<=10000)个目标,用整数Xi,Yi(其值在[0,5000])表示目标在地图上的位置,每个目标都有一个价值。激光炸弹的投放是通过卫星定位的,但其有一个缺点,就是其爆破范围,即那个边长为R的正方形的边必须和x,y轴平行。若目标位于爆破正方形的边上,该目标将不会被摧毁。 Input 输入文件...
2018-06-25 23:20:09
177
原创 POJ 1985 Strange Towers of Hanoi
题目:输出盘子为1~12的四柱汉诺塔问题的答案分析:设f(n)为四柱汉诺塔n盘子的答案;设d(n)为三柱汉诺塔n盘子的答案d(n)=d(n-1)*2+1f(n)=min{f(i)*2+d(n-i)}(0<=i<n)d的推导就不说了,关于f,可以发现所有的移动方法(A->D)都可以归结为以下三步①i个盘子通过四柱移动(A->B or C)步数为f(i)②剩下n-i个盘子通过三...
2018-06-25 22:29:01
186
原创 bailian 2811 熄灯问题
题目:5*6的格子,熄灯问题分析:这是一个指数型枚举:2^6(当然也可以是2^5)采用位运算只是要稍微注意一下,枚举的每一重都要将操作的变量更新,这里,输入的矩阵是不能操作的,应该找一个临时的矩阵,每一次操作的时候,先把输入的矩阵里面的内容复制过来,一开始没注意到,WA死了。。。代码:#include<iostream>#include<cstring>using na...
2018-06-25 22:09:23
217
原创 HDU 2054 A == B ?
题目:对两个任意数判断是否相等分析:注意不一定是整数,用BigDecimal代码:import java.math.BigDecimal;import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO ...
2018-06-25 21:10:40
152
原创 POJ 1995 Raising Modulo Numbers
题目:计算(A1^B1+A2^B2+ ... +AH^BH)mod MM (1 <= M <= 45000)H (1 <= H <= 45000)INPUT:第一行是组数每组第一行是M,第二行是H,后面H行是两个数Ai,BiOUTPUT:每行对应输出每组的答案分析:为了使中间结果不溢出,用快速幂的思路B分解为∑ci*2^i(0<=i<=k,k=log(B+1))...
2018-06-24 23:26:27
125
原创 数论总结
一、欧几里得算法(最大公约数,最小公倍数)又称辗转相除法,设a,b为整数,gcd(a,b)=gcd(b,a mod b);int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b);}//int gcd(int a,int b){ return b? gcd(b,a%b):a;}最小公倍数lcm满足lcm*gcd=a*b二、扩展...
2018-06-22 19:05:27
294
原创 POJ 2689 Prime Distance
题目:两个数L,U,(1<=L< U<=2,147,483,647)对于区间[L,U]内的所有相邻的素数,找到距离最小的那一对和距离最大的那一对INPUT:一行两个数L,U,相差不超过1,000,000.OUTPUT:按照示例输出最小相邻距离和最大相邻距离对应的一对数2,3 are closest, 7,11 are most distant.如果区间内的素数凑不成对,则输出Th...
2018-06-22 19:03:33
165
原创 POJ 1061青蛙的约会
题目:青蛙A的出发点坐标是x,青蛙B的出发点坐标是y。青蛙A一次能跳m米,青蛙B一次能跳n米,两只青蛙跳一次所花费的时间相同。纬度线总长L米。现在要你求出它们跳了几次以后才会碰面。INPUT:输入只包括一行5个整数x,y,m,n,L,其中x≠y < 2000000000,0 < m、n < 2000000000,0 < L < 2100000000。OUTPUT:输出...
2018-06-22 18:42:59
264
原创 HDU 1573 X问题
题目:求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0] X mod a[1] = b[1] X mod a[2] = b[2]00 … X mod a[i] = b[i]...(0 < a[i] <= 10,i<=M)INPUT:第一行是测试数据组数每一组第一行为N,M(0 < N <= 1000,000,000 , 0 < M <...
2018-06-22 18:27:22
192
原创 POJ 2891 Strange Way to Express Integers
题目:对于正整数a1, a2, …, ak,用m模得到对应余数 ri现在已知所有的整数对 (ai, ri) ,求对应的mINPUT:多组测试数据,每一组,第一行是k,后面k行每行是一个整数对 (ai, ri)OUTPUT:输出满足条件的最小正m,没有解输出-1分析:方程组:m≡ri(mod ai)假设m%a1=r1,m%a2=r2。那么我们将式子写开就变成了m=k1*a1+r1,m=k2*a2+r...
2018-06-22 17:52:31
131
原创 POJ 2115 C Looooops
题目:for (variable = A; variable != B; variable += C)statement;对于变量variable,在模1<<k的意义下,进行以上的循环,计算statement的计算次数,如果计算次数无限,输出“FOREVER”INPUT:一行四个数A,B,C,k,以0,0,0,0结尾(0<=A,B,C<(1<<K))OUTPUT...
2018-06-22 17:34:51
172
原创 POJ 2769 Reduced ID Numbers
题目:0~10^6范围内的整数,每个学生的ID对应其中之一,教授觉得数据范围太大不方便确定每一个学生,所以决定在每一组数据中找到最小的一个整数m,使得这一组的数据对m均不同余INPUT:第一行是数据组数,每一组数据第一行是学生数n,后面n行是n个ID(n不超过300)OUTPUT:对于每一组数据,输出最小的m分析:循环,从学生数n开始枚举,从1开始枚举也可以,虽然前一种枚举起点并没有优化太多b数组...
2018-06-22 17:18:33
190
原创 HDU 1085 Holding Bin-Laden Captive!
手动模拟一个一个因式的相乘过程两个系数数组交换存储答案数组的下标是多项式的指数1.HDU1085#include<iostream>#include<cstring>using namespace std;int n1[10000],n2[10000]; int main(){ int a,b,c; while(cin>>a>>b>...
2018-06-20 19:43:48
154
原创 java大数
HDU1002(加法)import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub int t; BigInteger a,b; Scan...
2018-06-19 23:30:45
133
原创 Mayor's posters POJ2528(线段树+离散化)
Mayor's postersPOJ - 2528 The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at thei...
2018-06-05 21:03:35
253
原创 Surround the Trees HDU 1392(计算几何+凸包)
Surround the TreesHDU - 1392 There are a lot of trees in an area. A peasant wants to buy a rope to surround all these trees. So at first he must know the minimal required length of the rope. However,...
2018-06-04 09:03:21
164
原创 Wall HDU1348(计算几何+凸包)
WallHDU - 1348 Once upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's p...
2018-06-04 08:56:04
263
原创 The Doors ZOJ 1721(计算几何+线段相交+最短路)
The DoorsZOJ - 1721You are to find the length of the shortest path through a chamber containing obstructing walls. The chamber will always have sides at x = 0, x = 10, y = 0, and y = 10. The initial a...
2018-06-04 08:48:48
207
原创 Pick-up sticks POJ2653(线段相交判断)
Pick-up sticksPOJ - 2653 Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that i...
2018-06-01 22:14:59
215
原创 A Round Peg in a Ground Hole POJ1584(判断凸包+判断点在多边形内+点到直线距离)
A Round Peg in a Ground HolePOJ - 1584 The DIY Furniture company specializes in assemble-it-yourself furniture kits. Typically, the pieces of wood are attached to one another using a woode...
2018-06-01 21:47:09
254
原创 Intersecting Lines POJ 1269(计算几何+判断直线间关系+求直线的交点)
Intersecting LinesPOJ - 1269 We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersectio...
2018-05-31 22:02:04
540
原创 Segments POJ3304(计算几何+叉乘的应用)
SegmentsPOJ - 3304 Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments on it, all projected se...
2018-05-31 20:41:39
207
原创 TOYS POJ2318 (计算几何+叉积的应用+二分)
TOYSPOJ - 2318 Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem - their child John never puts his toys away when he is finishe...
2018-05-31 19:32:38
191
原创 Monkey and Banana HDU - 1069(动归)
Monkey and BananaHDU - 1069 A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at the mean time, provide the monkey ...
2018-05-30 20:05:10
202
原创 Communication System POJ1018(动态规划)
Communication SystemPOJ - 1018 We have received an order from Pizoor Communications Inc. for a special communication system. The system consists of several devices. For each device, we are...
2018-05-28 15:16:28
496
原创 斐波那契的整除 NBUT - 1699(找规律)
NBUT - 1699 已知斐波那契数列有如下递归定义:f1=1,f2=1,且对n>=3,有fn=fn-1 + fn-2 ,它的前几项可以表示为1,1,2,3,5,8,13,21,34,...。问fn的值能否被3和4整除? Input 输入数据有若干组,每组数据包...
2018-05-28 08:35:50
218
原创 Balanced Lineup POJ3264(线段树模板题)
Balanced LineupPOJ - 3264 For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultimate Frisbee ...
2018-05-26 21:11:03
325
原创 计蒜客:公司营收(模拟)
计蒜客:公司营收(模拟)点击打开链接 一些公司之间有合作关系,会计小张想了解大家的贸易额的多少。在这个问题中的各家公司都有一个固定的资产输出,而这些资产输出将被平均分给和这家公司有贸易公司的人(资产不会出现小数,如果 333 的资产输出给 222 个公司,则每个被输出的公司得到 111,输出公司中剩余 111)。但是,这些公司中,有些公司的资产输出较多...
2018-05-26 17:53:10
303
原创 计蒜客:斐波那契数列(模拟)
计蒜客:斐波那契数列(模拟)点击打开链接 百度熊对数学一直都非常感兴趣。最近在学习斐波那契数列的它,向你展示了一个数字串,它称之为“斐波那契”串:111235813471123581347112358…聪明的你当然一眼就看出了这个串是这么构造的:1. 先写下两位在0~9范围内的数字a, b,构成串ab;2. 取串最后的两位数...
2018-05-26 17:01:04
261
原创 图论算法总结之六:最小生成树
六、最小生成树生成树:由一个图的所有点与部分边构成的连通又无回路的树最小生成树:权值最小的生成树1.Prim算法(1)思想:设置点集T,边集U,一开始T,U为空,首先任意选取一点V0加入T,更新所有以V0为端点的边的另一端点Vi到T中点的最小距离dis[i],然后进行以下操作:①选取不在T中的点vj,vj到T的距离是可选点中最小的,将vj加入T②将连接vj的边,而且另一端点不在T中的边加入U③更新...
2018-05-21 16:54:48
209
原创 POJ 1276 Cash Machine(dp+多重背包)
Cash MachinePOJ - 1276cash N n1 D1 n2 D2 ... nN DN最大面值和cash,面值数N,面值Di有ni张对给定数据,最大不超过cash,可以凑多少钱分析:一种物品——一个面值物品质量——面值不超过最大质量——不超过最大面值物品价值——面值最大价值——最大面值和注意这里面值既是质量也是价值, 就是一个简单的多重背包问题代码:#include<iostr...
2018-05-20 17:15:47
141
原创 组合数学基础
一、加法原理&乘法原理小学数学略二、错排问题当n个编号元素放在n个编号位置,编号与位置不对应的方法数用D(n)表示求解D(n):第一步,把第n个元素放在一个位置,比如位置k,一共有n-1种方法;第二步,放编号为k的元素,这时有两种情况:⑴把它放到位置n,那么,对于剩下的n-1个元素,由于第k个元素放到了位置n,剩下n-2个元素就有D(n-2)种方法;⑵第k个元素不把它放到位置n,这时,对于...
2018-05-20 10:20:35
700
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人