2018 ACM-ICPC 中国大学生程序设计竞赛暨丝绸之路程序设计竞赛
三道大水题,其它题都不会做,真是尴尬和无奈啊……
有想法,但是解决不了,感觉个人不会一些基本解法,终究还是个人学习的内容太少了
B. Goldbach
- /*
- 数值较小,<2^63,分解的两个素数较小,其中一个小于xxx(etc. 1e5)
- 生成1~x的素数:O(n)
- 判断素数不能只用已求出的素数相除,这样结果不对。而且这个方法速度太慢。
- Code largely studys from https://paste.ubuntu.com/p/JmDk43TTPB/
- 米勒拉宾素数测试
- https://www.cnblogs.com/cons/p/5188910.html
- 用unsigned long long 不明觉厉……
- */
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <list>
- #include <stack>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- #define ll unsigned long long
- const long maxn=1e6;
- //const ll mod=1e9+7;
- bool vis[maxn];
- long sum=;
- ll zhi[maxn];
- //由于考虑到取模数很大 快速幂会溢出
- ll add_mod(ll a,ll b,ll mod) //a*b = a*x1 + a*x2 + …
- {
- ll ans=;
- while (b)
- {
- if (b & )
- ans=(ans+a)%mod;
- a=(a<<)%mod;
- b>>=;
- }
- return ans;
- }
- ll pow_mod(ll a,ll b,ll mod) //a^b =a^(b/2)*a^(b/2) *a(if b%2==1)
- {
- if (b>)
- {
- ll tmp=pow_mod(a,b>>,mod);
- tmp=add_mod(tmp,tmp,mod);
- if (b & )
- tmp=add_mod(tmp,a,mod);
- return tmp;
- }
- return a;
- // ll r=1;
- // while (b)
- // {
- // if (b & 1)
- // r=r*a%mod;
- // a=a*a%mod;
- // b>>=1;
- // }
- // return r;
- }
- bool Miller_Rabbin(ll s,ll chu)
- {
- long ci=,i;
- ll d=s-; //ll
- while (!(d & )) //除成奇数
- {
- d>>=;
- ci++;
- }
- ll k=pow_mod(chu,d,s);
- if (k==) //第一个为奇数
- return ;
- for (i=;i<ci;i++,k=k*k%s)
- if (k==s-) //以后的为偶数
- return ;
- return ;
- }
- bool pan(ll s)
- {
- long i,g=;
- ll chu[]={,,,,};
- for (i=;i<g;i++)
- if (s==chu[i])
- return ;
- for (i=;i<g;i++)
- if (s%chu[i]==)
- return ;
- for (i=;i<g;i++)
- if (!Miller_Rabbin(s,chu[i]))
- return ;
- return ;
- // if (s<maxn)
- // return vis[s];
- // else
- // {
- // long i;
- // for (i=1;i<=ans;i++)
- // if (s%zhi[i]==0)
- // return false;
- // return true;
- // }
- }
- int main()
- {
- long i,j,t;
- ll n;
- for (i=;i<maxn;i++)
- vis[i]=true;
- for (i=;i<maxn;i++)
- {
- if (vis[i])
- {
- sum++;
- zhi[sum]=i;
- }
- for (j=;j<=sum;j++)
- {
- if (i*zhi[j]>=maxn)
- break;
- vis[i*zhi[j]]=false;
- if (i%zhi[j]==)
- break;
- }
- }
- scanf("%ld",&t);
- while (t--)
- {
- scanf("%llu",&n);
- for (i=;i<=sum;i++)
- if (pan(n-zhi[i]))
- {
- printf("%llu %llu\n",zhi[i],n-zhi[i]);
- break;
- }
- }
- return ;
- }
- /*
- 126
- 146
- 22222222222
- */
E. Copy and Submit II
运行题目程序一遍就知道了
内存超限(没删原程序的a数组) -> 编译错误(只删了原程序的a数组,没删其它a变量) -> 运行超时(按照题目的代码用cin) -> 运行超时(scanf没用EOF) -> 正确通过
满满的泪水………………………………………………………………………………………………………………………………………………………………………
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <list>
- #include <stack>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- #define ll long long
- const long maxn=1e6+;
- const ll mod=1e9+;
- int main()
- {
- int n,i;
- long long r,a;
- while (scanf("%ld",&n)!=EOF)
- {
- r=;
- for (i=;i<n;i++)
- {
- scanf("%lld",&a);
- r=r*(a+)%mod;
- }
- printf("%lld\n",r);
- }
- return ;
- }
I. Reversion Count
- //找个样例从头到尾调试一次,查看变量
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <list>
- #include <stack>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- #define ll long long
- const long maxn=1e6+;
- const ll mod=1e9+;
- long a[],b[],n;
- bool pan()
- {
- long i;
- //从高位到低位,之前写错了 ,其实无关紧要,结果能被9整除
- for (i=n;i>=;i--)
- if (a[i]>b[i])
- return true;
- else if (a[i]<b[i])
- return false;
- return false;
- }
- int main()
- {
- long i,t,x;
- char s[];
- // while (scanf("%s",s)!=EOF)
- while (cin>>s)
- {
- n=strlen(s);
- for (i=;i<=n;i++)
- a[i]=s[n-i]-;
- for (i=;i<=n;i++)
- b[i]=a[n+-i];
- if (!pan())
- {
- for (i=;i<=n;i++)
- {
- t=a[i];
- a[i]=b[i];
- b[i]=t;
- }
- }
- for (i=;i<=n;i++)
- {
- a[i]-=b[i];
- if (a[i]<)
- {
- a[i+]--;
- a[i]+=;
- }
- }
- x=;
- for (i=n;i>=;i--)
- {
- x=x*+a[i];
- a[i]=x/;
- x=x%;
- }
- while (n> && a[n]==)
- n--;
- //只使用一位数字,之前写错了
- while (n> && a[n]==a[n-])
- n--;
- if (n==)
- printf("YES\n");
- else
- printf("NO\n");
- }
- return ;
- }
L. Nise-Anti-AK Problem
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <list>
- #include <stack>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- #define ll long long
- const long maxn=1e6+;
- const ll mod=1e9+;
- long a[];
- int main()
- {
- long t,n,i;
- // for (i=1;i<=100;i++)
- // {
- // long sum=0;
- // for (int j=0;j<=i;j++)
- // sum+= (i | j);
- // printf("%ld\n",sum);
- // }
- scanf("%ld",&t);
- while (t--)
- {
- scanf("%ld",&n);
- for (i=;i<=n;i++)
- scanf("%ld",&a[i]);
- sort(a+,a+n+);
- printf("%ld\n",a[n]);
- }
- return ;
- }
2018 ACM-ICPC 中国大学生程序设计竞赛暨丝绸之路程序设计竞赛的更多相关文章
- 2018 ACM ICPC 南京赛区 酱油记
Day 1: 早上6点起床打车去车站,似乎好久没有这么早起床过了,困到不行,在火车上睡啊睡就睡到了南京.南航离南京南站很近,地铁一站就到了,在学校里看到了体验坐直升机的活动,感觉很强.报道完之后去吃了 ...
- 2018 ACM/ICPC 南京 I题 Magic Potion
题解:最大流板题:增加两个源点,一个汇点.第一个源点到第二个源点连边,权为K,然后第一个源点再连其他点(英雄点)边权各为1,然后英雄和怪物之间按照所给连边(边权为1). 每个怪物连终点,边权为1: 参 ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1001 - Buy and Resell 【优先队列维护最小堆+贪心】
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6438 Buy and Resell Time Limit: 2000/1000 MS (Java/O ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1010 YJJ's Salesman 【离散化+树状数组维护区间最大值】
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/O ...
- 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛
比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM ...
- 2018 ACM 国际大学生程序设计竞赛上海大都会部分题解
题目链接 2018 ACM 国际大学生程序设计竞赛上海大都会 下午午休起床被同学叫去打比赛233 然后已经过了2.5h了 先挑过得多的做了 .... A题 rand x*n 次点,每次judge一个点 ...
- 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)
2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...
- 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 F题 Clever King(最小割)
2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1009 - Tree and Permutation 【dfs+树上两点距离和】
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
随机推荐
- 【推荐系统】neural_collaborative_filtering(源码解析)
很久没看推荐系统相关的论文了,最近发现一篇2017年的论文,感觉不错. 原始论文 https://arxiv.org/pdf/1708.05031.pdf 网上有翻译了 https://www.cnb ...
- NO.4:自学python之路------内置方法、装饰器、迭代器
引言 是时候开始新的Python学习了,最近要考英语,可能不会周更,但是尽量吧. 正文 内置方法 Python提供给了使用者很多内置方法,可以便于编程使用.这里就来挑选其中大部分的内置方法进行解释其用 ...
- NO.2:自学tensorflow之路------BP神经网络编程
引言 在上一篇博客中,介绍了各种Python的第三方库的安装,本周将要使用Tensorflow完成第一个神经网络,BP神经网络的编写.由于之前已经介绍过了BP神经网络的内部结构,本文将直接介绍Tens ...
- 北美跨境电商平台Wish透露未来一年在华规划
9月12日,北美跨境电商平台Wish在深圳透露了未来一年在中国区的重点规划.Wish中国区总裁丁浩川表示,在下一阶段,Wish公司将继续围绕 提升平台流量. 加强品类支撑. 深化库存管理. 推进物流改 ...
- dos2unix命令详解
基础命令学习目录首页 原文链接:https://blog.csdn.net/leedaning/article/details/53024290 使用git 的时候碰到git将unix换行符转换为wi ...
- JS以及CSS对页面的阻塞
一.JS阻塞 所有的浏览器在下载JS文件的时候,会阻塞页面上的其他活动,包括其他资源的下载以及页面内容的呈现等等,只有当JS下载.解析.执行完,才会进行后面的 操作.在现代的浏览器中CSS资源和图片i ...
- 关于 Java连接sql的转载
Java连接SQL Server 2000数据库时,有两种方法: (1)通过Microsoft的JDBC驱动连接.此JDBC驱动共有三个文件,分别是mssqlserver.jar.msutil.jar ...
- Leetcode题库——28.实现strStr()
@author: ZZQ @software: PyCharm @file: strStr.py @time: 2018/11/6 20:04 要求:给定一个 haystack 字符串和一个 need ...
- JAVA 构造函数 静态变量
class HelloA { public HelloA() { System.out.println("HelloA"); } { System.out.println(&quo ...
- week4a:个人博客作业
本周结对项目的要求: 黄金点游戏是一个数字小游戏,其游戏规则是: N个同学(N通常大于10),每人写一个0~100之间的有理数 (不包括0或100),交给裁判,裁判算出所有数字的平均值,然后乘以0.6 ...