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=0; ll zhi[maxn];//由于考虑到取模数很大 快速幂会溢出 ll add_mod(ll a,ll b,ll mod) //a*b = a*x1 + a*x2 + … {ll ans=0;while (b){if (b & 1)ans=(ans+a)%mod;a=(a<<1)%mod;b>>=1;}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>1){ll tmp=pow_mod(a,b>>1,mod);tmp=add_mod(tmp,tmp,mod);if (b & 1)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=0,i;ll d=s-1; //llwhile (!(d & 1)) //除成奇数 {d>>=1;ci++;}ll k=pow_mod(chu,d,s);if (k==1) //第一个为奇数 return 1;for (i=0;i<ci;i++,k=k*k%s)if (k==s-1) //以后的为偶数 return 1;return 0; }bool pan(ll s) {long i,g=5;ll chu[]={2,3,5,7,11};for (i=0;i<g;i++)if (s==chu[i])return 1;for (i=0;i<g;i++)if (s%chu[i]==0)return 0;for (i=0;i<g;i++)if (!Miller_Rabbin(s,chu[i]))return 0;return 1;// 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=1;i<maxn;i++)vis[i]=true;for (i=2;i<maxn;i++){if (vis[i]){sum++;zhi[sum]=i;}for (j=1;j<=sum;j++){if (i*zhi[j]>=maxn)break;vis[i*zhi[j]]=false;if (i%zhi[j]==0)break;}}scanf("%ld",&t);while (t--){scanf("%llu",&n);for (i=1;i<=sum;i++)if (pan(n-zhi[i])){printf("%llu %llu\n",zhi[i],n-zhi[i]);break;}}return 0; } /* 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+5; const ll mod=1e9+7;int main() {int n,i;long long r,a;while (scanf("%ld",&n)!=EOF){r=1;for (i=0;i<n;i++){scanf("%lld",&a);r=r*(a+1)%mod;}printf("%lld\n",r);}return 0; }
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+5; 17 const ll mod=1e9+7; 18 19 long a[105],b[105],n; 20 21 bool pan() 22 { 23 long i; 24 //从高位到低位,之前写错了 ,其实无关紧要,结果能被9整除 25 for (i=n;i>=1;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[105]; 37 // while (scanf("%s",s)!=EOF) 38 while (cin>>s) 39 { 40 n=strlen(s); 41 for (i=1;i<=n;i++) 42 a[i]=s[n-i]-48; 43 for (i=1;i<=n;i++) 44 b[i]=a[n+1-i]; 45 if (!pan()) 46 { 47 for (i=1;i<=n;i++) 48 { 49 t=a[i]; 50 a[i]=b[i]; 51 b[i]=t; 52 } 53 } 54 for (i=1;i<=n;i++) 55 { 56 a[i]-=b[i]; 57 if (a[i]<0) 58 { 59 a[i+1]--; 60 a[i]+=10; 61 } 62 } 63 x=0; 64 for (i=n;i>=1;i--) 65 { 66 x=x*10+a[i]; 67 a[i]=x/9; 68 x=x%9; 69 } 70 while (n>1 && a[n]==0) 71 n--; 72 //只使用一位数字,之前写错了 73 while (n>1 && a[n]==a[n-1]) 74 n--; 75 if (n==1) 76 printf("YES\n"); 77 else 78 printf("NO\n"); 79 } 80 return 0; 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+5; 16 const ll mod=1e9+7; 17 18 long a[1005]; 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=1;i<=n;i++) 36 scanf("%ld",&a[i]); 37 sort(a+1,a+n+1); 38 printf("%ld\n",a[n]); 39 } 40 return 0; 41 }
转载于:https://www.cnblogs.com/cmyg/p/8908424.html
2018 ACM-ICPC 中国大学生程序设计竞赛暨丝绸之路程序设计竞赛相关推荐
- 十一届中国大学生计算机设计大赛,2018第十一届中国大学生计算机设计大赛福建农林大学站...
酷热的夏天不知不觉已过半,但是立秋已经来了炎热的福州一直处于高烧不退的状态.但是天气炎热,也抵挡不住来自全国各地的小伙伴们对比赛热情.全国各个高校代表队伍,纷至沓来的从各地舟车劳顿向赛场赶来.很荣幸福 ...
- 解题报告(一)F、(2018 ACM - ICPC shenyang I)Distance Between Sweethearts(数学期望 + 乘法原理 + FWT)(4.5)
繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量题解和代码,题目难度不一定按照题号排序,我会在每道题后面加上题目难度指数(1∼51 \sim 51∼5),以模板题难度 11 ...
- 北邮计算机学院acm,计算机学院学生在2018年ACM-ICPC中国大学生程序设计竞赛中喜获佳绩...
6月9日至6月10日,2018ACM-ICPC中国大学生程序设计竞赛在宁夏石嘴山市举行,本次大赛吸引了来自全国各大高校的132支参赛队伍,北京邮电大学共派出三支队伍参赛,均喜获佳绩. 经过五个小时的激 ...
- 2018 ACM ICPC Asia Regional - Seoul B.Cosmetic Survey
参考大佬代码 题目大意 nnn个顾客,mmm种画妆品,每一个顾客会给mmm种化妆品一个值,这个值代表这个化妆品在他心中的排名,排名越小越喜欢,如果这个值为0说明最不喜欢这一种化妆品(值为0理解为无穷大 ...
- 2018 ACM/ICPC 沈阳站小结
第二次现场赛,能拿金已经很开心了 热身赛 开幕式后的热身赛都是训练过的三个题,40min基本就解决了,剩下的时间就是在调试机器什么的 现场赛 上来队友先过了J的模拟,我看了看G题,发现可做就直接上了, ...
- 2018 ACM/ICPC 南京站小结
第一次打现场赛,又是在半主场,其实挺激动的,但是结果不尽人意 热身赛 开幕式后的热身赛就打得有些问题,四个题都不难,我们都想到了做法,但因为机时不够+细节问题导致前两个小时一直没有过题,然后AC的三道 ...
- 2018 ACM ICPC Arabella Collegiate Programming Contest A
Multiplication operation is not always easy! For example, it is hard to calculate 27 × 20 using your ...
- A - Multiplication Dilemma (思维)( 2018 ACM ICPC Arabella Collegiate Programming Contest)
滴答滴答---题目链接 Multiplication operation is not always easy! For example, it is hard to calculate 27 × 2 ...
- 2018 ACM/ICPC 北京赛区网络赛 D 80 Days 线段树
http://hihocoder.com/problemset/problem/1831?sid=1390457 描述 80 Days is an interesting game based on ...
最新文章
- 计算机前端专业术语,学习计算机知识必须懂得50个专业术语
- Elasticsearch之type底层结构及弃用原因
- 计算机hub体系部件,原来如此!USB Hub接口为啥都是4个7个或10个?
- 如何安装mysql5.6.16_centos安装mysql5.6.16
- 二叉查找树(BST Binary Search Tree)
- 数据库-优化-MYSQL数据库设计原则
- CodeForces - 897E Willem, Chtholly and Seniorious(珂朵莉树)
- python3 输入输出_Python3基础之输入和输出实例分析
- java项目中的pom依赖在哪_java – 如何包含pom项目中的所有模块
- 用 C 语言编写一个网络蜘蛛来搜索网上出现的电子邮件地址
- 几种常见排序算法时间复杂度
- 对计算机态度英语作文,对自动化的看法英语作文_专业高分英语作文2篇-波波英语...
- l3119双闪_打印机进纸灯和墨水灯双灯齐闪 解决方法
- 【python】语句
- Blender 快捷键笔记
- java时钟指针_时钟 走动 一个应用线程实现指针运动的指针时钟程序 联合开发网 - pudn.com...
- 160个常用黑客命令速查手册
- Android.mk编译错误 FAILED: ninja: unknown target ‘MODULES-IN-packages-apps-XXXX‘
- 保险精算--第五周作业
- 计算机中完成全选的快捷键,怎么全选-很实用!word中全选的快捷键介绍及使用方法...