题目地址:点击打开链接

还是太弱。

英文太差。,,

预计要等待被虐了。。

1077

找最长的公共后缀,暴力就能够写:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cmath>
  4. #include<algorithm>
  5. #include<cstring>
  6. #include<string>
  7. using namespace std;
  8.  
  9. char a[105][1005];
  10. int milen;
  11.  
  12. void myreverse(char *s)
  13. {
  14. int len=strlen(s);
  15. milen=min(len,milen);
  16. for(int i=0; i<len/2; i++)
  17. {
  18. char tmp=s[i];
  19. s[i]=s[len-1-i];
  20. s[len-1-i]=tmp;
  21. }
  22. }
  23.  
  24. int main()
  25. {
  26. int n,i,j;
  27.  
  28. while(cin>>n)
  29. {
  30. gets(a[0]);
  31. milen=10005;
  32.  
  33. for(i=0; i<n; i++)
  34. {
  35. gets(a[i]);
  36. myreverse(a[i]);
  37. }
  38.  
  39. for(i=0; i<milen; i++)
  40. {
  41. int flag=0;
  42. for(j=1; j<n; j++)
  43. {
  44. if(a[j][i]!=a[0][i])
  45. {
  46. flag=1;
  47. break;
  48. }
  49. }
  50. if(flag) break;
  51. }
  52.  
  53. int p=i;
  54. char ans[1005];
  55. for(i=0; i<p; i++)
  56. ans[i]=a[0][i];
  57. ans[i]='\0';
  58. myreverse(ans);
  59.  
  60. if(p==0) puts("nai");
  61. else printf("%s\n",ans);
  62.  
  63. }
  64. return 0;
  65. }
  66.  
  67. /*
  68. 3
  69. Itai nyan~
  70. Ninjin wa iyadanyan~
  71. uhhh nyan~
  72.  
  73. 3
  74. Itai!
  75. Ninjinnwaiyada T_T
  76. T_T
  77. */

1078:

hash散列啊,二次探測啊,单词看不懂。。

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<iostream>
  4. #include<cstring>
  5. #include<string>
  6. using namespace std;
  7. const int maxn=20005;
  8.  
  9. int prim[maxn];
  10. int mp[maxn];
  11. int tmpprim[maxn];
  12.  
  13. int visi[maxn];
  14. int ans[maxn];
  15.  
  16. void sxprim()
  17. {
  18. int i,j;
  19. memset(prim,1,sizeof(prim));
  20. prim[1]=0;
  21.  
  22. for(i=2;i<maxn;i++)
  23. {
  24. if(prim[i])
  25. {
  26. for(j=i*2;j<maxn;j+=i)
  27. prim[j]=0;
  28. }
  29. }
  30.  
  31. int cnt=0;
  32. for(i=maxn-1;i>=2;i--)
  33. {
  34. if(prim[i])
  35. tmpprim[cnt++]=i;
  36. }
  37.  
  38. for(i=0;i<cnt-1;i++)
  39. {
  40. int tmp=tmpprim[i];
  41. int k=tmpprim[i+1];
  42. for(j=tmp;j>k;j--)
  43. mp[j]=tmp;
  44. }
  45.  
  46. for(j=1;j<=tmpprim[cnt-1];j++)
  47. mp[j]=tmpprim[cnt-1];
  48.  
  49. //for(i=1;i<=20;i++)
  50. //cout<<i<<" "<<mp[i]<<endl;
  51. }
  52.  
  53. int main()
  54. {
  55. sxprim();
  56.  
  57. int mod,n,i;
  58.  
  59. while(cin>>mod>>n)
  60. {
  61. mod=mp[mod]; //re-defined
  62. memset(visi,0,sizeof(visi));
  63.  
  64. for(i=0;i<n;i++)
  65. {
  66. int x;
  67. cin>>x;
  68. int cur=x%mod;
  69. if(!visi[cur])
  70. {
  71. visi[cur]=1;
  72. ans[i]=cur;
  73. }
  74. else
  75. {
  76. int cnt=1;
  77. int flag=0;
  78. while(cnt<=maxn) //探測法都搞错了。。
  79. {
  80. int p=(cnt*cnt+cur)%mod;
  81. if(!visi[p])
  82. {
  83. visi[p]=1;
  84. ans[i]=p;
  85. flag=1;
  86. break;
  87. }
  88. cnt++;
  89. }
  90.  
  91. if(!flag)
  92. ans[i]=-1;
  93. }
  94. }
  95.  
  96. for(i=0;i<n;i++)
  97. {
  98. if(i) cout<<" ";
  99. if(ans[i]>=0) cout<<ans[i];
  100. else cout<<"-";
  101. }
  102. cout<<endl;
  103. }
  104. return 0;
  105. }
  106.  
  107. /*
  108. 11 8
  109. 2 2 2 2 2 2 2 2
  110. */

1079:

就是给你一颗树。找叶子结点,叶子结点有值,然后从根往下每一层会以r%添加。

不预处理会超时。。

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cmath>
  4. #include<cstring>
  5. #include<string>
  6. #include<algorithm>
  7. #include<vector>
  8. const int maxn=100005;
  9. using namespace std;
  10.  
  11. vector <int> mq[maxn];
  12. int n;
  13. double p,r;
  14.  
  15. /*double cal(int step)
  16. {
  17. double ans=p;
  18. for(int i=0; i<step; i++)
  19. ans=ans*(r/100.0+1.0);
  20. return ans;
  21.  
  22. }*/
  23.  
  24. double tt[maxn];
  25. void cal() //预处理之后就不会超时了,时间换空间
  26. {
  27. tt[0]=p;
  28. for(int i=1;i<maxn;i++)
  29. tt[i]=tt[i-1]*(1.0+r/100.0);
  30. }
  31.  
  32. int height[maxn];
  33. double val[maxn];
  34.  
  35. double ans;
  36.  
  37. void dfs(int cur)
  38. {
  39. int len=mq[cur].size();
  40. int i;
  41. if(len==0)
  42. {
  43. ans+=val[cur]*tt[height[cur]];
  44. return;
  45. }
  46. else
  47. {
  48. for(i=0;i<len;i++)
  49. {
  50. int p=mq[cur][i];
  51. height[p]=height[cur]+1;
  52. dfs(p);
  53. }
  54. }
  55. }
  56.  
  57. int main()
  58. {
  59. int i;
  60. while(cin>>n)
  61. {
  62. cin>>p>>r;
  63. cal();
  64. for(i=0; i<n; i++)
  65. mq[i].clear();
  66. height[0]=0;
  67.  
  68. int x,chi;
  69. for(i=0; i<n; i++)
  70. {
  71. cin>>x;
  72. if(x)
  73. {
  74. while(x--)
  75. {
  76. cin>>chi;
  77. mq[i].push_back(chi);
  78. }
  79. }
  80. else
  81. {
  82. cin>>val[i];
  83. }
  84. }
  85.  
  86. ans=0;
  87. dfs(0);
  88. printf("%.1f\n",ans);
  89. }
  90. return 0;
  91. }
  92.  
  93. /*
  94. 10 1.80 1.00
  95. 3 2 3 5
  96. 1 9
  97. 1 4
  98. 1 7
  99. 0 7
  100. 2 6 1
  101. 1 8
  102. 0 9
  103. 0 4
  104. 0 3
  105. */

1080:

这个最后也仅仅能拿24分/30分。有个错误。有个数据跑出来段错误。

我预计是数据是每一个学校定额有0的情况。

。不然错的没道理啊。。

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cmath>
  4. #include<cstring>
  5. #include<string>
  6. #include<algorithm>
  7. #include<vector>
  8. #include<set>
  9. const int maxn=40005;
  10. using namespace std;
  11.  
  12. int n,m,k;
  13. int peo[maxn];
  14. //set <int> ans[maxn];
  15. //set <int> ::iterator mq;
  16. vector <int> ans[105];
  17.  
  18. struct node
  19. {
  20. int index;
  21. int ge;
  22. int gi;
  23. int total;
  24. int aim[6];
  25. }nod[maxn];
  26.  
  27. struct nodd
  28. {
  29. int ge;
  30. int gi;
  31. }last[105]; //暂存每一个学校录取成绩最低的人。假设有同样成绩的也加进去
  32.  
  33. int cmp(node p1,node p2)
  34. {
  35. if(p1.total>p2.total) return 1;
  36. else if(p1.total==p2.total&&p1.ge>p2.ge) return 1;
  37. //else if(p1.total==p2.total&&p1.ge==p2.ge&&p1.gi>p2.gi) return 1;
  38. return 0;
  39. }
  40.  
  41. int main()
  42. {
  43. int i,j;
  44. int a[10];
  45. while(cin>>n>>m>>k)
  46. {
  47. for(i=0;i<n;i++)
  48. ans[i].clear();
  49. for(i=0;i<m;i++)
  50. cin>>peo[i];
  51.  
  52. for(i=0;i<n;i++)
  53. {
  54. cin>>nod[i].ge>>nod[i].gi;
  55. for(j=0;j<k;j++)
  56. cin>>nod[i].aim[j];
  57. nod[i].total=nod[i].ge+nod[i].gi;
  58. nod[i].index=i;
  59. }
  60.  
  61. sort(nod,nod+n,cmp);
  62. for(i=0;i<n;i++)
  63. {
  64. for(j=0;j<m;j++)
  65. a[j]=nod[i].aim[j];
  66. for(j=0;j<m;j++)
  67. {
  68. if(peo[a[j]])
  69. {
  70. peo[a[j]]--;
  71. ans[a[j]].push_back(nod[i].index);
  72. if(peo[a[j]]==0)
  73. {
  74. last[a[j]].ge=nod[i].ge;
  75. last[a[j]].gi=nod[i].gi;
  76. }
  77. break;
  78. }
  79. else
  80. {
  81. if(nod[i].ge==last[a[j]].ge&&nod[i].gi==last[a[j]].gi)
  82. {
  83. ans[a[j]].push_back(nod[i].index);
  84. break;
  85. }
  86. }
  87. }
  88. }
  89.  
  90. for(i=0;i<m;i++)
  91. {
  92. if(ans[i].size()==0) puts("");
  93. else
  94. {
  95. int len=ans[i].size();
  96. sort(ans[i].begin(),ans[i].end());
  97. /*mq=ans[i].begin();
  98.  
  99. int flag=0;
  100. for(;mq!=ans[i].end();mq++)
  101. {
  102. if(flag) cout<<" ";
  103. else flag=1;
  104. cout<<*mq;
  105. }*/
  106. for(j=0;j<len;j++)
  107. {
  108. if(j>0) cout<<" ";
  109. cout<<ans[i][j];
  110. }
  111. cout<<endl;
  112. }
  113. }
  114. }
  115. return 0;
  116. }
  117.  
  118. /*
  119. 11 6 3
  120. 2 1 2 2 2 3
  121. 100 100 0 1 2
  122. 60 60 2 3 5
  123. 100 90 0 3 4
  124. 90 100 1 2 0
  125. 90 90 5 1 3
  126. 80 90 1 0 2
  127. 80 80 0 1 2
  128. 80 80 0 1 2
  129. 80 70 1 3 2
  130. 70 80 1 2 3
  131. 100 100 0 2 4
  132. */

浙大PAT考试1077~1080(2014上机复试题目)的更多相关文章

  1. 浙大PAT考试1013~1016(最伤的一次。。)

    我能说我1016WA了几天都不得最后还是拿别人代码交的么. .. 真心找不到那个神数据.. . 自己把整个程序的流程都画出来了.细致推敲是木有问题的啊... 题目地址:点击打开链接 先从1013開始介 ...

  2. PAT 乙级 1077

    题目 题目地址:PAT 乙级 1077 题解 本题没什么难度,但是要注意细节问题,下面简单来说一下: vector 把输入的学生打分存起来,直接用算法库中的 sort 函数给它们排个序,之后直接剔除首 ...

  3. 浙大 PAT 乙级 1001-1075 目录索引

    1001. 害死人不偿命的(3n+1)猜想 1002. 写出这个数 1003. 我要通过! 1004. 成绩排名 1005. 继续(3n+1)猜想 1006. 换个格式输出整数 1007. 素数对猜想 ...

  4. PAT Basic 1077

    1077 互评成绩计算 在浙大的计算机专业课中,经常有互评分组报告这个环节.一个组上台介绍自己的工作,其他组在台下为其表现评分.最后这个组的互评成绩是这样计算的:所有其他组的评分中,去掉一个最高分和一 ...

  5. PAT(B) 1077 互评成绩计算(Java)

    题目链接:1077 互评成绩计算 (20 point(s)) 题目描述 在浙大的计算机专业课中,经常有互评分组报告这个环节.一个组上台介绍自己的工作,其他组在台下为其表现评分.最后这个组的互评成绩是这 ...

  6. 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 ...

  7. 浙江大学PAT考试1069~1072(2013-11-2)

    11 题目地址:http://pat.zju.edu.cn/contests/pat-a-practise 1069: 由下降序和上升序两个四位数不断相减,然后得到新数据,始终会到达一个数字终止. 递 ...

  8. 浙江大学PAT考试1009~1012(1010上帝是冠军。。)

    哎,pat1010即使java书面,只有java书面,还增加了两个点,,.啊,智商捉佳,主要pat有些不给明确的范围.造成遐想空间.. 还是按顺序介绍.. 题目地址:http://pat.zju.ed ...

  9. 浙大pat 1035题解

    1035. Password (20) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To prepare f ...

随机推荐

  1. axis2实践(二)Restful入门示例

    1. 实例说明 本示例直接参照了RESTful Web Services with Apache Axis2,本示例基本就是沿用的原示例,就是一个对学生信息(包括姓名,年龄,课程)的管理的例子,提供如 ...

  2. cf 834 E. Ever-Hungry Krakozyabra

    cf 834 E. Ever-Hungry Krakozyabra(爆搜+数位dp) 题意: 定义一种inedible tail为一个数把每一位数字按不降的顺序排列后,去掉前导0组成的序列 比如570 ...

  3. 多校4 lazy running (最短路)

    lazy running(最短路) 题意: 一个环上有四个点,从点2出发回到起点,走过的距离不小于K的最短距离是多少 \(K <= 10^{18} 1 <= d <= 30000\) ...

  4. BZOJ3622 已经没有什么好害怕的了 【dp + 二项式反演】

    题目链接 BZOJ3622 题解 既已开题 那就已经没有什么好害怕的了 由题目中奇怪的条件我们可以特判掉\(n - k\)为奇数时答案为\(0\) 否则我们要求的就是糖果大于药片恰好有\(\frac{ ...

  5. (poj)Sequence Median

    Description Given a sequence of N nonnegative integers. Let's define the median of such sequence. If ...

  6. code forces 996BWorld Cup

    B. World Cup time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  7. Java面试题之类加载器有哪些?什么是双亲委派模型

    类加载器有哪些: 1.启动类加载器(Bootstrap ClassLoader):这个类加载器负责将存放在<JAVA_HOME>\lib目录中的,或被-Xbootclasspath参数所指 ...

  8. POJ1200 Crazy Search

    Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Description Many peo ...

  9. glRotatef 转动方向

    http://blog.sina.com.cn/s/blog_3c6889fe0100qko6.html glRotatef(GLfloat angle,GLfloat x,GLfloat y,GLf ...

  10. 5.OpenStack添加镜像服务

    添加镜像服务 这里是安装在控制器上 创建数据库 mysql -uroot -ptoyo123 CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glanc ...