08 2019 档案
摘要:题意:在给定区域内找出一列递减的序列,输出长度即可。 思路:这一题之前写过两遍,是利用dfs进行搜索记录长度。 注意:记忆化搜索的本质是遇到已经计算过的点直接返回该值即可,不需要进行标记。但是为啥返回的时候步数不用-1我也不知道。。 先上之前dfs过的代码: 1 #include<stdio.h>
阅读全文
摘要:感觉这样看的比较清楚。 题意: 给出n和a,判断能否求出a^n+b^n=c^n中b和c的值,若可以输出b和c,否则则输出-1 -1。 思路: 数据给的比较大,但是题目很简单,套两个公式:费马打定理和奇偶数列法则分类讨论即可。 以下是对这两个法则的介绍: 费马大定理: 当整数n >2时,关于x, y,
阅读全文
摘要:题意: 给出t组数据,每组数据再给出num和time,代表下面共有三首歌曲和总共演唱时间,要求求出最长演唱时间和最多歌曲数量,输出时长,若是还有剩余时间,则可以演唱长为678s的歌曲 再给出一组数据 1 3 100 100 100 100 输出:678 为什么我一开始会想到用暴力来写。。。我只想到了
阅读全文
摘要:The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies
阅读全文
摘要:测试数据 Sample Input 3 BAPC BAPC AZA AZAZAZA VERDI AVERDXIVYERDIAN Sample Output 1 3 0 题意 计算模式串在原串中出现的次数 KMP 对于next数组的理解是理解kmp的关键。 next[i]:记录的是前后缀最长公共长度。
阅读全文
摘要:As we all know, the next Olympic Games will be held in Beijing in 2008. So the year 2008 seems a little special somehow. You are looking forward to it
阅读全文
摘要:I hope you know the beautiful Union-Find structure. In this problem, you’re to implement something similar, but not identical. The data structure you
阅读全文
摘要:Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29 (the rest of the d
阅读全文
摘要:给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等 Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c...y,z组成的字符串S 两组case之间由空行隔开(该空行不用处理)
阅读全文
摘要:The Tourist Guide Mr. G. works as a tourist guide. His current assignment is to take some tourists from one city to another. Some two-way roads connec
阅读全文
摘要:动态规划 判断一个字符串是不是回文串: 重新申请一个空间,将原串倒序再和原串进行比较。 在原有的字符串进行比较,比较第一个和最后一个是否相等,,再比较第二个倒数第二个是否相同。 https://mp.weixin.qq.com/s/Zrj35DrnQKtAENiR5llrcw
阅读全文
摘要:Given the value of N, you will have to find the value of G. The definition of G is given below:
阅读全文
摘要:As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B. T
阅读全文
摘要:欧拉定理: 若正整数 a , n 互质,则 aφ(n)≡1(mod n) 其中 φ(n) 是欧拉函数(1~n) 与 n 互质的数。 费马小定理: 对于质数p,任意整数a,均满足:ap≡a(mod p) 欧拉定理的推论: 若正整数a,n互质,那么对于任意正整数b,有ab≡ab mod φ(n)(mod
阅读全文
摘要:Mathematically some problems look hard. But with the help of the computer, some problems can be easily solvable. In this problem, you will be given tw
阅读全文
摘要:1 int degree_in_fact(int n, int x)//求n!中素数x的次数 2 {3 if(m) 4 return degree_in_fact(n/x,x)+n/x; 5 return 0; 6 }
阅读全文
摘要:昨天了解到,原来scanf输入也会超时。。。真的还有好多需要学习的。 由于暂时遇不到几百万的输入量,所以暂时没法总结自己的经验。 先放着等遇到题目再回过头来总结。 https://blog.csdn.net/qingshui23/article/details/51077914 https://ww
阅读全文
摘要:A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24
阅读全文
摘要:输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。 输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。 输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。 输入 第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 100
阅读全文
摘要:You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1*2*...*N. For e
阅读全文
摘要:Goldbach's conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states: Every even integer, greater than 2
阅读全文
摘要:It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the fi
阅读全文
摘要:In mathematics, the nth harmonic number is the sum of the reciprocals of the first n natural numbers: In this problem, you are given n, you have to fi
阅读全文
摘要:Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only i
阅读全文
摘要:Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves
阅读全文
摘要:度度熊正在学习双端队列,他对其翻转和合并产生了很大的兴趣。 初始时有 NN 个空的双端队列(编号为 11 到 NN ),你要支持度度熊的 QQ 次操作。 ①11 uu ww valval 在编号为 uu 的队列里加入一个权值为 valval 的元素。(w=0w=0 表示加在最前面,w=1w=1 表示
阅读全文
摘要:精度问题:double定义的变量,要是限制小数点的话,最好用.f 输出。OJ上G++double精确小数点要用.f提交,不然WA cin可以输入 "Mark" 或 "Twain",但不能输入 "Mark Twain",因为 cin 不能输入包含嵌入空格的字符串。 在C语言中余数的符号是和分母的符号相
阅读全文
摘要:前序的第一个是整个树的根 后序的最后一个是整个树的根 中序用来判别左右子树的划分 前序序列中左子树部分的第一个节点是左子树的根节点 前序序列中右子树部分的第一个节点是右子树的根节点 前序序列的特点可知树根后面紧接着的应当是左子树的树根 二叉树的先序、中序、后序遍历序列 https://blog.cs
阅读全文
摘要:Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in t
阅读全文
摘要:题目描述 给定一个由括号组成的字符串 问其是否为一个合法的括号序列 合法的括号序列的定义如下 1. 空字符串是合法的括号序列 2. 若字符串A是合法的括号序列, 那么{A},[A],(A)也是合法的括号序列 3. 若字符串A,B是合法的括号序列, AB也是合法的括号序列 例如 {} ,[] , ({
阅读全文
摘要:In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic
阅读全文
摘要:For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One day Farmer John decides to organize a game of Ultim
阅读全文
摘要:C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生
阅读全文
摘要:BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical commun
阅读全文
摘要:题意:C:对区间[l,r]每一个数+c; Q:查询区间[l,r]的所有元素的总和。 线段树修改和查找的时间复杂度都是O(logn)。线段树基本思想:分治。线段树基本操作:建树、区间查询(最值;和)、区间修改(更新)、单点修改、单点查询。 注意这题,输入说是一行 N、q 单组输入,但是会TLE,多组输
阅读全文