- 博客(75)
- 收藏
- 关注
转载 1088. Rational Arithmetic (20) PAT
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;long long gcd(long long a,long long b){ if(a<0){ a=-a; } if(b<0){ b=-b;...
2018-11-20 13:39:00 348
原创 神经网络
#TensorFlow——神经网络样例程序import tensorflow as tffrom numpy.random import RandomState#定义训练数据batch的大小,在不能将数据一次性通过神经网络的时候,就需要将数据集分成几个batch。batch_size = 8#定义神经网络的参数w1 = tf.Variable(tf.random_normal(...
2018-11-20 13:35:39 364
原创 蓝桥杯 表格计算
#include#include#include#include#includeusing namespace std;double res[100][100];string str[100][100];int flag[100][100];double sum(int,int,int,int);double avg(int,int,int,int);double stdd(
2017-03-31 21:01:40 807
原创 PAT 1119. Pre- and Post-order Traversals (30)
#include#include#include#includeusing namespace std;int n,pre[35],post[35],flag=0;int ans[35],k;struct node{ int num; struct node* left; struct node* right;};struct node* build(struct n
2016-12-01 20:10:26 590
原创 PAT 1010. Radix (25)
#include#include#includeusing namespace std;int get(char ch){ if(ch>='0'&&ch<='9'){ return ch-'0'; } else if(ch>='a'&&ch<='z'){ return ch-'a'+10; }}long long change(string str,long long
2016-12-01 20:08:51 382
原创 PAT 1018. Public Bike Management (30)
#include#include#includeusing namespace std;int a[101][101],vis[101],dis[101];int bike[101],bike2[101],capacity[101],parent[101];int dij(int c,int n,int p){ vis[0]=1; bike[0]=0; for(int i=1;i
2016-12-01 20:06:51 409
原创 ccf 最优灌溉
问题描述 雷雷承包了很多片麦田,为了灌溉这些麦田,雷雷在第一个麦田挖了一口很深的水井,所有的麦田都从这口井来引水灌溉。 为了灌溉,雷雷需要建立一些水渠,以连接水井和麦田,雷雷也可以利用部分麦田作为“中转站”,利用水渠连接不同的麦田,这样只要一片麦田能被灌溉,则与其连接的麦田也能被灌溉。 现在雷雷知道哪些麦田之间可以建设水渠和建设每个水渠所需要的费用(注意不是所有麦田之间都可以建立水渠
2016-09-11 19:53:00 613
原创 ccf 网络延时
#include#include#include#include#includeusing namespace std;vector vec[20010];//数组大小应该是m+nint n,m,vis[20010]; int d[20010],ans=-1,temp;int bfs(int node){ memset(vis,0,sizeof(vis)); memset(
2016-09-11 19:51:29 422
原创 ccf 送货
#include#include#include#include#includeusing namespace std;vector a[1001];int main(){ int n,m,x,y,count=0; scanf("%d%d",&n,&m); memset(a,0,sizeof(a)); for(int i=0;i<m;i++){ scanf("%d%d",
2016-09-11 19:46:59 369
原创 ccf 消除类游戏
#include#include#include#includeusing namespace std;int main(){ int a[35][35],b[35][35]; int n,m; scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&a[i][j]);
2016-09-11 19:44:57 489
原创 ccf 游戏
#include#include#include#includeusing namespace std;struct state{ int x,y,step;}; struct node{ int a,b,date; node(){ date=0; b=0; a=0; }}v[101][101];int n,m,t,book[101][101][201];//
2016-09-11 19:41:40 447
原创 会场安排问题 nyoj
#include#include#include#includeusing namespace std;int n,m,ans;struct node{ int B,E;}a[10001];/*超时int book[1001];void dfs(int t,int count,int end);int main(){ scanf("%d",&n); while(n--)
2016-09-02 16:47:26 465
原创 喷水装置(一) nyoj
#include#include#include #include#include#includeusing namespace std;double ri[601];int com(double a,double b){ return a>b;}int main(){ int n,m; scanf("%d",&n); while(n--){ scanf("%d",
2016-09-02 13:48:06 451
原创 喷水装置(二) nyoj
#include#include#include #include#include#includeusing namespace std;struct node{ double l;//装置的左端点 double r;//装置的右端点}a[10001];int com(struct node a,struct node b){ return a.l<b.l;//按照左端点排
2016-09-02 13:46:27 416
原创 1079. Total Sales of Supply Chain (25)
#include#include#include#include#includeusing namespace std;int N;double M,r;int amount[100001];vector a[100001];double sale;void dfs(int n,double m){// cout<<m<<endl; if(a[n].size()==0){
2016-06-09 11:22:31 498
原创 L3-008. 喊山 天梯初赛
#include#include#include#include#includeusing namespace std;int N,M,K;vector G[10001];struct node{ int num; int level;};int vis[10001],pro[10001];int ans,level;int bfs(int num){ vis[num
2016-06-07 19:59:42 1145
原创 PAT 天梯赛初赛
L2-009. 抢红包#include#include#include#include#include#includeusing namespace std;int N;struct node{ int id; double money; int cnt; node(){ id=-1; money=0; cnt=0; }}person[10001];i
2016-06-07 19:55:39 1339
原创 1078. Hashing (25) PAT
二次探测法,只考虑正增量。#include#include#include#includeusing namespace std;int Hash[10001];int Msize,N;int prime(int n){ int k=sqrt(n); int flag=0; if(n==0||n==1){ return 2; } if(n==2||n==3){
2016-06-03 20:32:43 491
原创 1076. Forwards on Weibo (30) PAT
简单题,随便搜一下就好了注意题目意思,M[i]是user_list [ i ]的粉丝#include#include#include#include#includeusing namespace std;vector user[1001];int N,L,ans;int vis[1001];struct node{ int id; int level;};voi
2016-06-03 19:23:13 491
原创 1083. List Grades (25) PAT
简单题#include#include#include#include#include#includeusing namespace std;struct node{ string name; string id; int grade;}stu[100000];int N,a,b;int com(struct node a,struct node b){ retur
2016-06-03 17:12:33 418
原创 1081. Rational Sum (20) PAT
#include #include #include #include #include #include using namespace std; int a[105]; //分子long long b[105]; //分母 long long gcd(long long a,long long b){ //最大公约数 return b==
2016-06-03 16:49:50 585
原创 1082. Read Number in Chinese (25) PAT
注意细节,比如大小写,零的处理,以及空格#include#include#include#include#include#includeusing namespace std;mapm;mapmm;int pp=0;string solve(string str){ string tmp=""; if(str.length()==1&&str[0]=='0'){ r
2016-06-03 16:45:01 475
原创 1080. Graduate Admission (30) PAT
看清题目的几点要求,没有难度#include#include#include#include#include#includeusing namespace std;mapm;//标记学生号码和排名,方便剪枝 int N,M,K;int quota[101];struct node{ int num; int Ge,Gi; double Gf; int rank;
2016-06-02 21:24:12 454
原创 1084. Broken Keyboard (20) PAT
不区分大小写,输出大写字母。#include#include#include#includeusing namespace std;mapm;int main(){ string str1,str2; char ch; cin>>str1>>str2; for(int i=0,j=0;i<str1.length();){ if(str1[i]>='a'&&str1[i]<=
2016-06-02 11:10:58 452
原创 1085. Perfect Sequence (25) PAT
二分查找#include#include#include#include#includeusing namespace std;long long N,p;vector a;int main(){ int x; scanf("%d%d",&N,&p); for(int i=0;i<N;i++){ scanf("%d",&x); a.push_back(x); }
2016-06-01 18:10:16 518
原创 1087. All Roads Lead to Rome (30) PAT
最短路径和dfs,先用dijkstra找出最短路径,然后用深搜找出相同路径的数量以及最佳答案;可以用map来标注city变量设的略乱,囧!#include#include#include#include#includeusing namespace std;int N,K;mapm;//标记城市名字mapmm;int G[205][205];int h[205],vis
2016-05-31 19:48:38 511
原创 1088. Rational Arithmetic (20)
PAT测试不支持%I64d 可以使用%lld,,被坑了好久。但是题目没有难度#include#include#include#includeusing namespace std;long long gcd(long long a,long long b){ if(a<0){ a=-a; } if(b<0){ b=-b; } long long t; if(a<b
2016-05-30 21:10:34 361
原创 HDU Today 2112
最短路径问题,城市名字可用map标记一下#include#include#include#include#includeusing namespace std;map m;int a[155][155];int vis[155],dis[155],N;string s,e;int dij(int n){ int ss=m[s]; vis[ss]=1; int nex
2016-05-26 19:42:54 427
原创 N任务
#include#include#include#include #includeusing namespace std;struct node{ int time; int wei; friend bool operator <(node a,node b){ a.wei>b.wei; }}a[1005];int n;int com(struct node a,s
2016-05-26 19:39:24 572
原创 1428 活动安排问题
#include#include#include#include#includeusing namespace std;struct node{ int stime; int ftime; friend bool operator<(node a,node b){ return a.ftime>b.ftime; }}a[10005];int n,vis[10005];
2016-05-26 19:38:11 493
原创 1483 化学反应
#include#include#include#include#includeusing namespace std;int vis[300005];int a[100005];int cnt[300005];int n;int solve(int t){// cout<<t<<endl; int step=0; int temp=t; while(temp<=10
2016-05-26 19:33:05 446
原创 1770 数数字
分两种情况1:a*b9 循环找到第一个相同的数字 #include#include#includeusing namespace std;int main(){ int T; scanf("%d",&T); while(T--){ int a,b,d,n; int ans=0,c=0,cnt=0; scanf("%d%d%d%d",&a,&b,&d,&n);
2016-05-26 19:31:11 516
原创 最大的奖励 51nod
大神学长讲的思路注意最后的答案应该是long long型#include#include#include#include#includeusing namespace std;struct node{ int time; int wei; friend bool operator <(node a,node b){ return a.wei>b.wei; }}a[
2016-05-23 20:44:20 370
原创 最大的数 nyoj 1170
#include#include#include#includeusing namespace std;int a[10001];int add(int a,int b);int main(){ int n; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ scanf("%d",&a[i]); } if(a[0
2016-05-21 20:30:31 456
原创 P1004 滑雪 tyvj
记忆化搜索#include#include#include#includeusing namespace std;int G[102][102],vis[102][102];int r,c,maxn;int dx[4]={0,1,0,-1};int dy[4]={1,0,-1,0};int dfs(int x,int y,int cnt);int main(){ whi
2016-05-21 19:30:31 395
原创 STAMPS POJ 1010
dfs 注意题目中的要求。满足顾客需求的解就是可行解。邮票种类最多的可行解为最优。如果存在两个以上的最优解的邮票种类是一样的,张数最少的更优张数也一样的话,这些最优解中最大面值较大的更优。若邮票种类、张数、最大面值三者都分别相同,则认为这些最优解相同,输出tie。没有解就是none。#include#include#include#includeusing namespace std
2016-05-21 16:42:46 428
原创 团体程序设计天梯赛
L01-009 N个数求和#include#include#include#include#include#includeusing namespace std;int a[105];long long b[105];long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}long
2016-05-19 21:43:49 1041
原创 nyoj 881 小M的区间公约数
题目http://acm.nyist.net/JudgeOnline/problem.php?pid=881#include#include#include#include#include#includeusing namespace std;vectorv;int main(){ int a,b; while(scanf("%d%d",&a,&b)!=EOF){//保证可以输
2016-05-17 21:58:32 377
原创 P1117 拯救ice-cream tyvj
简单的bfs题目http://www.tyvj.cn/p/1117#include#include#include#include#include#includeusing namespace std;int m,n,time;char a[50][50];int vis[50][50];int dx[4]={0,0,1,-1};int dy[4]={1,-1,0,0};
2016-05-17 18:46:12 507
原创 L3-004. 肿瘤诊断 天梯赛模拟题
三维的bfs题目https://www.patest.cn/contests/gplt/L3-004#include#include#include#includeusing namespace std;int g[65][130][1300];int n,m,l,tt,ans;int dx[6]={0,0,-1,1,0,0};int dy[6]={0,0,0,0,1,-1
2016-05-16 17:16:15 1289
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人