A Count Task Problem Description Count is one of WNJXYK's favorite tasks. Recently, he had a very long string and he wondered that how many substrings which contains exactly one kind of lowercase in this long string. But this string is so long that h…
素数判断2 比较简单的算法,没有技术含量 A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of N integers and prints th…
练习题目二 素数判断 A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of N integers and prints the number o…
A - Serval and Bus It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for…
sort函数 前言:当进行贪心算法的学习时,需要用到sort函数,因为初学c++汇编语言,sort的具体用法没有深入学习,所以这里进行sort学习记录并只有基础用法并借用贪心算法题目的代码. 百度百科:用于C++中,对给定区间所有元素进行排序.头文件是#include algorithm. 编译代码 #include<iostream> #include<algorithm> using namespace std; #define MAXN 100 struct node{ in…
原题:牛客网 动态规划dynamic programming 的入门级题目 题目描述 : 给你一个长度为50的数字串,问你有多少个子序列构成的数字可以被3整除 答案对1e9+7取模 输入描述: 输入一个字符串,由数字构成,长度小于等于50 输出描述: 输出一个整数 示例 输入: 132 输出: 3 正确代码 #include <bits/stdc++.h> using namespace std; const int Mod=1e9+7; int dp[3]; char a1[55]; int…
浅入动态规划 dynamic programming is a method for solving a complex problem by breaking it down into a collection of simpler subproblems. 最近进行动态规划的学习,看到了一个很好的例子,现在把它记录下来仅供自我知识梳理 1. 从一个生活问题谈起 作者:阮行止 先来看看生活中经常遇到的事吧--假设您是个土豪,身上带了足够的1.5.10.20.50.100元面值的钞票.现在您的目…
STL初步 提交ACM会TLE /仅以学习STL与迭代器使用 C. Cards Sorting time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this…
测试程序 #include<iostream> #include<cstring> using namespace std; int a[204],b[204],lena,n; char s1[100]="12345"; char s2[100]="abcdefg"; char s3[100]="ABCDE"; int main() { strncat (s1,s2,3);//s1="12345abc"…
552. 学生出勤记录 II 给定一个正整数 n,返回长度为 n 的所有可被视为可奖励的出勤记录的数量. 答案可能非常大,你只需返回结果mod 109 + 7的值. 学生出勤记录是只包含以下三个字符的字符串: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场 如果记录不包含多于一个'A'(缺勤)或超过两个连续的'L'(迟到),则该记录被视为可奖励的. 示例 1: 输入: n = 2 输出: 8 解释: 有8个长度为2的记录将被视为可奖励: "PP&qu…