三道大水题,其它题都不会做,真是尴尬和无奈啊……

有想法,但是解决不了,感觉个人不会一些基本解法,终究还是个人学习的内容太少了

B. Goldbach

  1. /*
  2. 数值较小,<2^63,分解的两个素数较小,其中一个小于xxx(etc. 1e5)
  3. 生成1~x的素数:O(n)
  4. 判断素数不能只用已求出的素数相除,这样结果不对。而且这个方法速度太慢。
  5.  
  6. Code largely studys from https://paste.ubuntu.com/p/JmDk43TTPB/
  7.  
  8. 米勒拉宾素数测试
  9. https://www.cnblogs.com/cons/p/5188910.html
  10.  
  11. 用unsigned long long 不明觉厉……
  12. */
  13.  
  14. #include <cstdio>
  15. #include <cstdlib>
  16. #include <cstring>
  17. #include <cmath>
  18. #include <list>
  19. #include <stack>
  20. #include <vector>
  21. #include <set>
  22. #include <map>
  23. #include <queue>
  24. #include <algorithm>
  25. #include <iostream>
  26. using namespace std;
  27. #define ll unsigned long long
  28. const long maxn=1e6;
  29. //const ll mod=1e9+7;
  30.  
  31. bool vis[maxn];
  32. long sum=;
  33. ll zhi[maxn];
  34.  
  35. //由于考虑到取模数很大 快速幂会溢出
  36. ll add_mod(ll a,ll b,ll mod) //a*b = a*x1 + a*x2 + …
  37. {
  38. ll ans=;
  39. while (b)
  40. {
  41. if (b & )
  42. ans=(ans+a)%mod;
  43. a=(a<<)%mod;
  44. b>>=;
  45. }
  46. return ans;
  47. }
  48.  
  49. ll pow_mod(ll a,ll b,ll mod) //a^b =a^(b/2)*a^(b/2) *a(if b%2==1)
  50. {
  51. if (b>)
  52. {
  53. ll tmp=pow_mod(a,b>>,mod);
  54. tmp=add_mod(tmp,tmp,mod);
  55. if (b & )
  56. tmp=add_mod(tmp,a,mod);
  57. return tmp;
  58. }
  59. return a;
  60.  
  61. // ll r=1;
  62. // while (b)
  63. // {
  64. // if (b & 1)
  65. // r=r*a%mod;
  66. // a=a*a%mod;
  67. // b>>=1;
  68. // }
  69. // return r;
  70. }
  71.  
  72. bool Miller_Rabbin(ll s,ll chu)
  73. {
  74. long ci=,i;
  75. ll d=s-; //ll
  76. while (!(d & )) //除成奇数
  77. {
  78. d>>=;
  79. ci++;
  80. }
  81. ll k=pow_mod(chu,d,s);
  82. if (k==) //第一个为奇数
  83. return ;
  84. for (i=;i<ci;i++,k=k*k%s)
  85. if (k==s-) //以后的为偶数
  86. return ;
  87. return ;
  88. }
  89.  
  90. bool pan(ll s)
  91. {
  92. long i,g=;
  93. ll chu[]={,,,,};
  94. for (i=;i<g;i++)
  95. if (s==chu[i])
  96. return ;
  97. for (i=;i<g;i++)
  98. if (s%chu[i]==)
  99. return ;
  100. for (i=;i<g;i++)
  101. if (!Miller_Rabbin(s,chu[i]))
  102. return ;
  103. return ;
  104.  
  105. // if (s<maxn)
  106. // return vis[s];
  107. // else
  108. // {
  109. // long i;
  110. // for (i=1;i<=ans;i++)
  111. // if (s%zhi[i]==0)
  112. // return false;
  113. // return true;
  114. // }
  115. }
  116.  
  117. int main()
  118. {
  119. long i,j,t;
  120. ll n;
  121. for (i=;i<maxn;i++)
  122. vis[i]=true;
  123. for (i=;i<maxn;i++)
  124. {
  125. if (vis[i])
  126. {
  127. sum++;
  128. zhi[sum]=i;
  129. }
  130. for (j=;j<=sum;j++)
  131. {
  132. if (i*zhi[j]>=maxn)
  133. break;
  134. vis[i*zhi[j]]=false;
  135. if (i%zhi[j]==)
  136. break;
  137. }
  138. }
  139.  
  140. scanf("%ld",&t);
  141. while (t--)
  142. {
  143. scanf("%llu",&n);
  144. for (i=;i<=sum;i++)
  145. if (pan(n-zhi[i]))
  146. {
  147. printf("%llu %llu\n",zhi[i],n-zhi[i]);
  148. break;
  149. }
  150. }
  151. return ;
  152. }
  153. /*
  154. 126
  155. 146
  156. 22222222222
  157. */

E. Copy and Submit II

运行题目程序一遍就知道了

内存超限(没删原程序的a数组) -> 编译错误(只删了原程序的a数组,没删其它a变量) -> 运行超时(按照题目的代码用cin) -> 运行超时(scanf没用EOF) -> 正确通过

满满的泪水………………………………………………………………………………………………………………………………………………………………………

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <list>
  6. #include <stack>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <algorithm>
  12. #include <iostream>
  13. using namespace std;
  14. #define ll long long
  15. const long maxn=1e6+;
  16. const ll mod=1e9+;
  17.  
  18. int main()
  19. {
  20. int n,i;
  21. long long r,a;
  22. while (scanf("%ld",&n)!=EOF)
  23. {
  24. r=;
  25. for (i=;i<n;i++)
  26. {
  27. scanf("%lld",&a);
  28. r=r*(a+)%mod;
  29. }
  30. printf("%lld\n",r);
  31. }
  32. return ;
  33. }

I. Reversion Count

  1. //找个样例从头到尾调试一次,查看变量
  2. #include <cstdio>
  3. #include <cstdlib>
  4. #include <cstring>
  5. #include <cmath>
  6. #include <list>
  7. #include <stack>
  8. #include <vector>
  9. #include <set>
  10. #include <map>
  11. #include <queue>
  12. #include <algorithm>
  13. #include <iostream>
  14. using namespace std;
  15. #define ll long long
  16. const long maxn=1e6+;
  17. const ll mod=1e9+;
  18.  
  19. long a[],b[],n;
  20.  
  21. bool pan()
  22. {
  23. long i;
  24. //从高位到低位,之前写错了 ,其实无关紧要,结果能被9整除
  25. for (i=n;i>=;i--)
  26. if (a[i]>b[i])
  27. return true;
  28. else if (a[i]<b[i])
  29. return false;
  30. return false;
  31. }
  32.  
  33. int main()
  34. {
  35. long i,t,x;
  36. char s[];
  37. // while (scanf("%s",s)!=EOF)
  38. while (cin>>s)
  39. {
  40. n=strlen(s);
  41. for (i=;i<=n;i++)
  42. a[i]=s[n-i]-;
  43. for (i=;i<=n;i++)
  44. b[i]=a[n+-i];
  45. if (!pan())
  46. {
  47. for (i=;i<=n;i++)
  48. {
  49. t=a[i];
  50. a[i]=b[i];
  51. b[i]=t;
  52. }
  53. }
  54. for (i=;i<=n;i++)
  55. {
  56. a[i]-=b[i];
  57. if (a[i]<)
  58. {
  59. a[i+]--;
  60. a[i]+=;
  61. }
  62. }
  63. x=;
  64. for (i=n;i>=;i--)
  65. {
  66. x=x*+a[i];
  67. a[i]=x/;
  68. x=x%;
  69. }
  70. while (n> && a[n]==)
  71. n--;
  72. //只使用一位数字,之前写错了
  73. while (n> && a[n]==a[n-])
  74. n--;
  75. if (n==)
  76. printf("YES\n");
  77. else
  78. printf("NO\n");
  79. }
  80. return ;
  81. }

L. Nise-Anti-AK Problem

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <list>
  6. #include <stack>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <algorithm>
  12. #include <iostream>
  13. using namespace std;
  14. #define ll long long
  15. const long maxn=1e6+;
  16. const ll mod=1e9+;
  17.  
  18. long a[];
  19.  
  20. int main()
  21. {
  22. long t,n,i;
  23. // for (i=1;i<=100;i++)
  24. // {
  25. // long sum=0;
  26. // for (int j=0;j<=i;j++)
  27. // sum+= (i | j);
  28. // printf("%ld\n",sum);
  29. // }
  30.  
  31. scanf("%ld",&t);
  32. while (t--)
  33. {
  34. scanf("%ld",&n);
  35. for (i=;i<=n;i++)
  36. scanf("%ld",&a[i]);
  37. sort(a+,a+n+);
  38. printf("%ld\n",a[n]);
  39. }
  40. return ;
  41. }

2018 ACM-ICPC 中国大学生程序设计竞赛暨丝绸之路程序设计竞赛的更多相关文章

  1. 2018 ACM ICPC 南京赛区 酱油记

    Day 1: 早上6点起床打车去车站,似乎好久没有这么早起床过了,困到不行,在火车上睡啊睡就睡到了南京.南航离南京南站很近,地铁一站就到了,在学校里看到了体验坐直升机的活动,感觉很强.报道完之后去吃了 ...

  2. 2018 ACM/ICPC 南京 I题 Magic Potion

    题解:最大流板题:增加两个源点,一个汇点.第一个源点到第二个源点连边,权为K,然后第一个源点再连其他点(英雄点)边权各为1,然后英雄和怪物之间按照所给连边(边权为1). 每个怪物连终点,边权为1: 参 ...

  3. 2018中国大学生程序设计竞赛 - 网络选拔赛 1001 - Buy and Resell 【优先队列维护最小堆+贪心】

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6438 Buy and Resell Time Limit: 2000/1000 MS (Java/O ...

  4. 2018中国大学生程序设计竞赛 - 网络选拔赛 1010 YJJ's Salesman 【离散化+树状数组维护区间最大值】

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/O ...

  5. 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛

    比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM ...

  6. 2018 ACM 国际大学生程序设计竞赛上海大都会部分题解

    题目链接 2018 ACM 国际大学生程序设计竞赛上海大都会 下午午休起床被同学叫去打比赛233 然后已经过了2.5h了 先挑过得多的做了 .... A题 rand x*n 次点,每次judge一个点 ...

  7. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  8. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 F题 Clever King(最小割)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  9. 2018中国大学生程序设计竞赛 - 网络选拔赛 1009 - Tree and Permutation 【dfs+树上两点距离和】

    Tree and Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

随机推荐

  1. 【推荐系统】neural_collaborative_filtering(源码解析)

    很久没看推荐系统相关的论文了,最近发现一篇2017年的论文,感觉不错. 原始论文 https://arxiv.org/pdf/1708.05031.pdf 网上有翻译了 https://www.cnb ...

  2. NO.4:自学python之路------内置方法、装饰器、迭代器

    引言 是时候开始新的Python学习了,最近要考英语,可能不会周更,但是尽量吧. 正文 内置方法 Python提供给了使用者很多内置方法,可以便于编程使用.这里就来挑选其中大部分的内置方法进行解释其用 ...

  3. NO.2:自学tensorflow之路------BP神经网络编程

    引言 在上一篇博客中,介绍了各种Python的第三方库的安装,本周将要使用Tensorflow完成第一个神经网络,BP神经网络的编写.由于之前已经介绍过了BP神经网络的内部结构,本文将直接介绍Tens ...

  4. 北美跨境电商平台Wish透露未来一年在华规划

    9月12日,北美跨境电商平台Wish在深圳透露了未来一年在中国区的重点规划.Wish中国区总裁丁浩川表示,在下一阶段,Wish公司将继续围绕 提升平台流量. 加强品类支撑. 深化库存管理. 推进物流改 ...

  5. dos2unix命令详解

    基础命令学习目录首页 原文链接:https://blog.csdn.net/leedaning/article/details/53024290 使用git 的时候碰到git将unix换行符转换为wi ...

  6. JS以及CSS对页面的阻塞

    一.JS阻塞 所有的浏览器在下载JS文件的时候,会阻塞页面上的其他活动,包括其他资源的下载以及页面内容的呈现等等,只有当JS下载.解析.执行完,才会进行后面的 操作.在现代的浏览器中CSS资源和图片i ...

  7. 关于 Java连接sql的转载

    Java连接SQL Server 2000数据库时,有两种方法: (1)通过Microsoft的JDBC驱动连接.此JDBC驱动共有三个文件,分别是mssqlserver.jar.msutil.jar ...

  8. Leetcode题库——28.实现strStr()

    @author: ZZQ @software: PyCharm @file: strStr.py @time: 2018/11/6 20:04 要求:给定一个 haystack 字符串和一个 need ...

  9. JAVA 构造函数 静态变量

    class HelloA { public HelloA() { System.out.println("HelloA"); } { System.out.println(&quo ...

  10. week4a:个人博客作业

    本周结对项目的要求: 黄金点游戏是一个数字小游戏,其游戏规则是: N个同学(N通常大于10),每人写一个0~100之间的有理数 (不包括0或100),交给裁判,裁判算出所有数字的平均值,然后乘以0.6 ...