浙大PAT考试1077~1080(2014上机复试题目)
题目地址:点击打开链接
还是太弱。
。
英文太差。,,
预计要等待被虐了。。
1077
找最长的公共后缀,暴力就能够写:
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<algorithm>
- #include<cstring>
- #include<string>
- using namespace std;
- char a[105][1005];
- int milen;
- void myreverse(char *s)
- {
- int len=strlen(s);
- milen=min(len,milen);
- for(int i=0; i<len/2; i++)
- {
- char tmp=s[i];
- s[i]=s[len-1-i];
- s[len-1-i]=tmp;
- }
- }
- int main()
- {
- int n,i,j;
- while(cin>>n)
- {
- gets(a[0]);
- milen=10005;
- for(i=0; i<n; i++)
- {
- gets(a[i]);
- myreverse(a[i]);
- }
- for(i=0; i<milen; i++)
- {
- int flag=0;
- for(j=1; j<n; j++)
- {
- if(a[j][i]!=a[0][i])
- {
- flag=1;
- break;
- }
- }
- if(flag) break;
- }
- int p=i;
- char ans[1005];
- for(i=0; i<p; i++)
- ans[i]=a[0][i];
- ans[i]='\0';
- myreverse(ans);
- if(p==0) puts("nai");
- else printf("%s\n",ans);
- }
- return 0;
- }
- /*
- 3
- Itai nyan~
- Ninjin wa iyadanyan~
- uhhh nyan~
- 3
- Itai!
- Ninjinnwaiyada T_T
- T_T
- */
1078:
hash散列啊,二次探測啊,单词看不懂。。
- #include<cstdio>
- #include<cmath>
- #include<iostream>
- #include<cstring>
- #include<string>
- using namespace std;
- const int maxn=20005;
- int prim[maxn];
- int mp[maxn];
- int tmpprim[maxn];
- int visi[maxn];
- int ans[maxn];
- void sxprim()
- {
- int i,j;
- memset(prim,1,sizeof(prim));
- prim[1]=0;
- for(i=2;i<maxn;i++)
- {
- if(prim[i])
- {
- for(j=i*2;j<maxn;j+=i)
- prim[j]=0;
- }
- }
- int cnt=0;
- for(i=maxn-1;i>=2;i--)
- {
- if(prim[i])
- tmpprim[cnt++]=i;
- }
- for(i=0;i<cnt-1;i++)
- {
- int tmp=tmpprim[i];
- int k=tmpprim[i+1];
- for(j=tmp;j>k;j--)
- mp[j]=tmp;
- }
- for(j=1;j<=tmpprim[cnt-1];j++)
- mp[j]=tmpprim[cnt-1];
- //for(i=1;i<=20;i++)
- //cout<<i<<" "<<mp[i]<<endl;
- }
- int main()
- {
- sxprim();
- int mod,n,i;
- while(cin>>mod>>n)
- {
- mod=mp[mod]; //re-defined
- memset(visi,0,sizeof(visi));
- for(i=0;i<n;i++)
- {
- int x;
- cin>>x;
- int cur=x%mod;
- if(!visi[cur])
- {
- visi[cur]=1;
- ans[i]=cur;
- }
- else
- {
- int cnt=1;
- int flag=0;
- while(cnt<=maxn) //探測法都搞错了。。
- {
- int p=(cnt*cnt+cur)%mod;
- if(!visi[p])
- {
- visi[p]=1;
- ans[i]=p;
- flag=1;
- break;
- }
- cnt++;
- }
- if(!flag)
- ans[i]=-1;
- }
- }
- for(i=0;i<n;i++)
- {
- if(i) cout<<" ";
- if(ans[i]>=0) cout<<ans[i];
- else cout<<"-";
- }
- cout<<endl;
- }
- return 0;
- }
- /*
- 11 8
- 2 2 2 2 2 2 2 2
- */
1079:
就是给你一颗树。找叶子结点,叶子结点有值,然后从根往下每一层会以r%添加。
不预处理会超时。。
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<cstring>
- #include<string>
- #include<algorithm>
- #include<vector>
- const int maxn=100005;
- using namespace std;
- vector <int> mq[maxn];
- int n;
- double p,r;
- /*double cal(int step)
- {
- double ans=p;
- for(int i=0; i<step; i++)
- ans=ans*(r/100.0+1.0);
- return ans;
- }*/
- double tt[maxn];
- void cal() //预处理之后就不会超时了,时间换空间
- {
- tt[0]=p;
- for(int i=1;i<maxn;i++)
- tt[i]=tt[i-1]*(1.0+r/100.0);
- }
- int height[maxn];
- double val[maxn];
- double ans;
- void dfs(int cur)
- {
- int len=mq[cur].size();
- int i;
- if(len==0)
- {
- ans+=val[cur]*tt[height[cur]];
- return;
- }
- else
- {
- for(i=0;i<len;i++)
- {
- int p=mq[cur][i];
- height[p]=height[cur]+1;
- dfs(p);
- }
- }
- }
- int main()
- {
- int i;
- while(cin>>n)
- {
- cin>>p>>r;
- cal();
- for(i=0; i<n; i++)
- mq[i].clear();
- height[0]=0;
- int x,chi;
- for(i=0; i<n; i++)
- {
- cin>>x;
- if(x)
- {
- while(x--)
- {
- cin>>chi;
- mq[i].push_back(chi);
- }
- }
- else
- {
- cin>>val[i];
- }
- }
- ans=0;
- dfs(0);
- printf("%.1f\n",ans);
- }
- return 0;
- }
- /*
- 10 1.80 1.00
- 3 2 3 5
- 1 9
- 1 4
- 1 7
- 0 7
- 2 6 1
- 1 8
- 0 9
- 0 4
- 0 3
- */
1080:
这个最后也仅仅能拿24分/30分。有个错误。有个数据跑出来段错误。
我预计是数据是每一个学校定额有0的情况。
。不然错的没道理啊。。
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<cstring>
- #include<string>
- #include<algorithm>
- #include<vector>
- #include<set>
- const int maxn=40005;
- using namespace std;
- int n,m,k;
- int peo[maxn];
- //set <int> ans[maxn];
- //set <int> ::iterator mq;
- vector <int> ans[105];
- struct node
- {
- int index;
- int ge;
- int gi;
- int total;
- int aim[6];
- }nod[maxn];
- struct nodd
- {
- int ge;
- int gi;
- }last[105]; //暂存每一个学校录取成绩最低的人。假设有同样成绩的也加进去
- int cmp(node p1,node p2)
- {
- if(p1.total>p2.total) return 1;
- else if(p1.total==p2.total&&p1.ge>p2.ge) return 1;
- //else if(p1.total==p2.total&&p1.ge==p2.ge&&p1.gi>p2.gi) return 1;
- return 0;
- }
- int main()
- {
- int i,j;
- int a[10];
- while(cin>>n>>m>>k)
- {
- for(i=0;i<n;i++)
- ans[i].clear();
- for(i=0;i<m;i++)
- cin>>peo[i];
- for(i=0;i<n;i++)
- {
- cin>>nod[i].ge>>nod[i].gi;
- for(j=0;j<k;j++)
- cin>>nod[i].aim[j];
- nod[i].total=nod[i].ge+nod[i].gi;
- nod[i].index=i;
- }
- sort(nod,nod+n,cmp);
- for(i=0;i<n;i++)
- {
- for(j=0;j<m;j++)
- a[j]=nod[i].aim[j];
- for(j=0;j<m;j++)
- {
- if(peo[a[j]])
- {
- peo[a[j]]--;
- ans[a[j]].push_back(nod[i].index);
- if(peo[a[j]]==0)
- {
- last[a[j]].ge=nod[i].ge;
- last[a[j]].gi=nod[i].gi;
- }
- break;
- }
- else
- {
- if(nod[i].ge==last[a[j]].ge&&nod[i].gi==last[a[j]].gi)
- {
- ans[a[j]].push_back(nod[i].index);
- break;
- }
- }
- }
- }
- for(i=0;i<m;i++)
- {
- if(ans[i].size()==0) puts("");
- else
- {
- int len=ans[i].size();
- sort(ans[i].begin(),ans[i].end());
- /*mq=ans[i].begin();
- int flag=0;
- for(;mq!=ans[i].end();mq++)
- {
- if(flag) cout<<" ";
- else flag=1;
- cout<<*mq;
- }*/
- for(j=0;j<len;j++)
- {
- if(j>0) cout<<" ";
- cout<<ans[i][j];
- }
- cout<<endl;
- }
- }
- }
- return 0;
- }
- /*
- 11 6 3
- 2 1 2 2 2 3
- 100 100 0 1 2
- 60 60 2 3 5
- 100 90 0 3 4
- 90 100 1 2 0
- 90 90 5 1 3
- 80 90 1 0 2
- 80 80 0 1 2
- 80 80 0 1 2
- 80 70 1 3 2
- 70 80 1 2 3
- 100 100 0 2 4
- */
浙大PAT考试1077~1080(2014上机复试题目)的更多相关文章
- 浙大PAT考试1013~1016(最伤的一次。。)
我能说我1016WA了几天都不得最后还是拿别人代码交的么. .. 真心找不到那个神数据.. . 自己把整个程序的流程都画出来了.细致推敲是木有问题的啊... 题目地址:点击打开链接 先从1013開始介 ...
- PAT 乙级 1077
题目 题目地址:PAT 乙级 1077 题解 本题没什么难度,但是要注意细节问题,下面简单来说一下: vector 把输入的学生打分存起来,直接用算法库中的 sort 函数给它们排个序,之后直接剔除首 ...
- 浙大 PAT 乙级 1001-1075 目录索引
1001. 害死人不偿命的(3n+1)猜想 1002. 写出这个数 1003. 我要通过! 1004. 成绩排名 1005. 继续(3n+1)猜想 1006. 换个格式输出整数 1007. 素数对猜想 ...
- PAT Basic 1077
1077 互评成绩计算 在浙大的计算机专业课中,经常有互评分组报告这个环节.一个组上台介绍自己的工作,其他组在台下为其表现评分.最后这个组的互评成绩是这样计算的:所有其他组的评分中,去掉一个最高分和一 ...
- PAT(B) 1077 互评成绩计算(Java)
题目链接:1077 互评成绩计算 (20 point(s)) 题目描述 在浙大的计算机专业课中,经常有互评分组报告这个环节.一个组上台介绍自己的工作,其他组在台下为其表现评分.最后这个组的互评成绩是这 ...
- A题进行时--浙大PAT 1001-1010
pat链接:http://pat.zju.edu.cn 1 #include<stdio.h> 2 int main(){ 3 int a,b; 4 int c; 5 while(scan ...
- 浙江大学PAT考试1069~1072(2013-11-2)
11 题目地址:http://pat.zju.edu.cn/contests/pat-a-practise 1069: 由下降序和上升序两个四位数不断相减,然后得到新数据,始终会到达一个数字终止. 递 ...
- 浙江大学PAT考试1009~1012(1010上帝是冠军。。)
哎,pat1010即使java书面,只有java书面,还增加了两个点,,.啊,智商捉佳,主要pat有些不给明确的范围.造成遐想空间.. 还是按顺序介绍.. 题目地址:http://pat.zju.ed ...
- 浙大pat 1035题解
1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...
随机推荐
- axis2实践(二)Restful入门示例
1. 实例说明 本示例直接参照了RESTful Web Services with Apache Axis2,本示例基本就是沿用的原示例,就是一个对学生信息(包括姓名,年龄,课程)的管理的例子,提供如 ...
- cf 834 E. Ever-Hungry Krakozyabra
cf 834 E. Ever-Hungry Krakozyabra(爆搜+数位dp) 题意: 定义一种inedible tail为一个数把每一位数字按不降的顺序排列后,去掉前导0组成的序列 比如570 ...
- 多校4 lazy running (最短路)
lazy running(最短路) 题意: 一个环上有四个点,从点2出发回到起点,走过的距离不小于K的最短距离是多少 \(K <= 10^{18} 1 <= d <= 30000\) ...
- BZOJ3622 已经没有什么好害怕的了 【dp + 二项式反演】
题目链接 BZOJ3622 题解 既已开题 那就已经没有什么好害怕的了 由题目中奇怪的条件我们可以特判掉\(n - k\)为奇数时答案为\(0\) 否则我们要求的就是糖果大于药片恰好有\(\frac{ ...
- (poj)Sequence Median
Description Given a sequence of N nonnegative integers. Let's define the median of such sequence. If ...
- code forces 996BWorld Cup
B. World Cup time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Java面试题之类加载器有哪些?什么是双亲委派模型
类加载器有哪些: 1.启动类加载器(Bootstrap ClassLoader):这个类加载器负责将存放在<JAVA_HOME>\lib目录中的,或被-Xbootclasspath参数所指 ...
- POJ1200 Crazy Search
Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u Description Many peo ...
- glRotatef 转动方向
http://blog.sina.com.cn/s/blog_3c6889fe0100qko6.html glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLf ...
- 5.OpenStack添加镜像服务
添加镜像服务 这里是安装在控制器上 创建数据库 mysql -uroot -ptoyo123 CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glanc ...