随笔分类 - ACM_杂题
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1230第i位表示的实际大小是前i 个素数的乘积那么多,(第0位表示1) 进位规则是这一位减去p[i] (例如第0位减去p[0]==2) 高以为加1 ,由于更加难进位了,所以加法先相加,然后一次进位扫描就能保证每一位在范围内。 输入输出有点麻烦,是这个题的考点吧代码:#include
#include
#include
#include
#include
using namespace std; int p[101]; vector prime; int na[25];
int nb[25];...
阅读全文
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3786题目思路: 我们用p[i]=j 来表示 i 的孩子是j (因为一个parent只有一个孩子,但是一个孩子有两个parent不好形成对应)然后初始化为-1,这样如果遇到父母不清楚的(‘-’) 还是-1,一遇到就break掉,把count还原为0; 如果是家族树上存在的两个结点,那么一定可以通过这样知道他们相隔的代数,于是就可以知道相应的称谓 一堆if-else 比较考基本功代码:#include
#include
#include
using namespace std; int p[26];.
阅读全文
摘要:题目地址:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2666这个题的意思有点没说清楚,不知道最频繁指的什么,后来队友指点,直接开一个1440大的数组存每一分钟的状态,然后找出最大的次数,然后第一次出现这样的次数的一段。为了统计,在最后补了一个-1;代码:#include
#include
#include
#include
using namespace std; string format(int n)
{
阅读全文
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1861 一个研究生入学考试上机题==b思路: 将信息放在结构体里,然后存在向量中, 最后扫描到n==0就统计,输出,清空向量。 需要注意的是 1 同一艘船可能出租两次,于是扫描到op=='E' 时,就要立马处理。 2 扫描到op=='E' 时 ,还要看是否有S的记录,如果没有找到就不处理 3 从00:00 -> 00:00 算是借了一分钟~ 而不是差值0分钟 4 字符串和整数之间转化 用stringstream ,#includ...
阅读全文
摘要:题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2612题解: 1 只用找到星号的位置,然后比较两端 2使用algorithm中的反转比较方便,不用管第二段开始的位置 3 容易忽略的地方,至少b要和a去掉星号后一样长啊,否则 a*a 和a这种情况也匹配了 4要求多多的输入输出,不说了代码:#include
#include
#include
#include
using namespace std; int match(string a,string b) // a i...
阅读全文
摘要:题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=698题解: 额,水题一个,一点思维量都没有,就是逻辑判断理顺就好了。 耍赖使用了goto#include
#include
using namespace std; int isvowel(char ch)
{ if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') return 1; else return 0; }
int isconsonan
阅读全文
摘要:题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1315题解 : 1 一个很简单的题 没有什么算法在里面,完全考输入输出,基本功 。 2 很奇怪 每个案例后面总是输出一个空行,和一般的要求不一样 3 每次在调用cin.getline() 时 先用调用一次,吃掉前面cin没有管的回车换行符 4 判断某一个关键词在不在这个借口中时,将这个关键词一步步的移动,逐一去匹配,还要注意的是,即便匹配成功,这个关键词前面和后面不可以有字母,所以还要对匹配成功的地址进行特判。#include
#...
阅读全文
摘要:题目地址 :http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1420思路:一开始看这个题觉得题意简单但不同的月份有不同的天数,有点不知怎么方便的解决。 然后想到打表的方法,把每一天的信息作为一个结构体,一一存在向量里面,向量的角标是自增的,刚好就是里2000-01-01的天数。注意 :1 闰年的判断2输出格式 1-1要写成 01-013 超内存问题 要把三个属性值设置成 short int ,直接int会超内存4 星期问题,2000-01-01是周六 所以第n天就是 周(n+6)%7代码:#include
#include
阅读全文
摘要:#include #include
#include
using namespace std; int main()
{ //ifstream cin("testdata.txt"); int n=0; cin>>n; for(int l=0;l>size; int *p=new int[size]; for(int i=0;i>p[i]; int begin=0; int end=0; int sum=0; int maxsum=...
阅读全文
摘要:题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1003#include #include
#include
using namespace std; int main()
{ //ifstream cin("testdata.txt"); int n=0; cin>>n; for(int l=0;l>size; int *p=new int[size]; for(int i=0;i>p[i]; int begin=0; ...
阅读全文
摘要:#include#includeusing namespace std;int main(){ int size=0; cin>>size; /*char * p=new char[100]; char * q=new char[100];*/ string p=""; string q=""; int * result=new int[1001]; for(int l=0;l>p>>q; string p_backup=p; string q_backup=q; int n=p.length(); int m=q.leng
阅读全文
浙公网安备 33010602011771号