05 2018 档案
摘要:原型: char *strchr(const char *s,char c); #include<string.h> 查找字符串s中首次出现字符c的位置,返回首次出现c的位置的指针,如果s中不存在c则返回NULL。
阅读全文
摘要:fgets()函数简介 读字符串函数fgets()的功能是从指定的文件中读一个字符串到字符数组中,函数调用的形式为: fgets(字符数组名,n,文件指针),要从键盘输入时文件指针的参数为:stdin ; 其中的n是一个正整数。表示从文件中读出的字符串不超过 n-1个字符。在读入的最后一个字符后加上
阅读全文
摘要:题意: 设一个等差数列,首元素为a,公差为d 现在要求输入a,d,n ,要求找出属于该等差数列中的第n个素数并输出 思路:空间换时间是个主旋律。素数表的生成用素数筛选法。方法是从2开始,对每个目前还标记为素数的数(初始情况下每个数都标记为素数),把它的所有倍数都标记为非素数。这些扫描过去后,一直没被
阅读全文
摘要:题意:给你至多100行超大整数,以0结束输入,要求你求出这些超大整数的和。 高精度加法运算 例如19999 + 999 + 9,看图更清晰 1、以字符串格式读入超大整数,然后将每一位转换成整型并逆序存放在数组中。 2、把每次读入字符串的长度存放在0号元素中(sum[i][0])。 3、将所有大整数的
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 #define N 1000005 6 7 bool prime[N];//int会超内存 8 9 void dabiao()//筛法求素数 10 { 11 int i,j; 12 prime[0]=prime[1]=1; 13 1...
阅读全文
摘要:Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description The famous ACM (Advanced Computer Maker) Company
阅读全文
摘要:注意事项: 不要轻易中途变换思路修改代码 发现有样例无法通过可以用if强行通过 注意输入输出形式(long long为lld,无符号为llu)。 开过1亿的int型数组 Long long能读入输出19位数 调用函数时是否有放入参数 调用函数的参数是否在合理范围内(米勒素数的参数应从2开始) 不要在
阅读全文
摘要:Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given po
阅读全文
摘要:#include//用于求一个图存在多少个强连通分量 #include #include using namespace std; #define maxn 1000000 vectormp[maxn]; int vis[maxn];//标记该点是否被tarjan int dfn[maxn];//时间戳 int low[maxn];//low为该点能追溯到的最根的祖先 int n,m,c...
阅读全文
摘要:Description Given a connected undirected graph, tell if its minimum spanning tree is unique. Definition 1 (Spanning Tree): Consider a connected, undir
阅读全文
摘要:Description The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two different communication te
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 #define N 5 6 7 void ps(set s) 8 { 9 set::iterator i; 10 for (i=s.begin();i!=s.end();i++) 11 { 12 printf("...
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include //定义pair的头文件 6 using namespace std; 7 #define N 5 8 9 map m; 10 11 void pm()//map输出函数 12 { 13 map::iterator i1; 14 for ...
阅读全文
摘要:在c++中,vector是一个十分有用的容器。 作用:它能够像容器一样存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。 vector在C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。 为了使用vector,必
阅读全文
摘要:一、List定义: List是stl实现的双向链表,与向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢。使用时需要添加头文件 #include <list> 二、List定义和初始化: list<int>lst1; //创建空list list<int> lst2(5);
阅读全文
摘要:另外要注意sort()的排序范围:数组a[ ]下标从0开始,sort(a+1,a+5)的范围是a[1]~a[4],是左闭右开区间!! 给字符串a本排序:sort(a.begin(),a.begin()+a.size());
阅读全文
摘要:知识点: (1) 随机取一个 a (2)如果 它不满足 a^(n-1)%n ==1 (3)则它一定是 合数 (4)退出 (5)如果它满足 a^(n-1)%n ==1 (6)则它是一个素数的概率是1/2 (7)回到 (1) if n < 2,152,302,898,747, it is enough
阅读全文
摘要:Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each oth
阅读全文
摘要:Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9216 Accepted Submission(s): 6805 Problem Descrip
阅读全文
摘要:Truck History Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 31871 Accepted: 12427 Description Advanced Cargo Movement, Ltd. uses trucks o
阅读全文