c++
浩渺千星
这个作者很懒,什么都没留下…
展开
-
P1157 组合的输出
题目链接参考题解思路:先用一个数组模拟数字的出现情况,0表示输出的数字,例如样例中的n = 5, r = 3:1234500011如上表,此时输出为1 2 3;之后使用next_permutation()列举出所有情况,输出,ac。代码#include <iostream>#include <iomanip>#include <algorithm>using namespace std;int ans[30]原创 2021-03-16 19:55:50 · 304 阅读 · 1 评论 -
Codeforces 1480A. Yet Another String Game
题目地址题目大意一段由小写英文字母组成的字符串,从第一个字母开始,Alice会把这个字母改成除了这个字母以外字典序列最小的字母,Bob改成字母数列最大的字母。Alice先手,当所有的字母全部被操作一遍后,输出操作后的字符串。思路1、轮到Alice时直接把非a字母改成a,字母a改成b;2、轮到Bob时把非z字母改成z,字母z改成y。#include <iostream>#include <string>using namespace std;string str;原创 2021-02-17 13:17:04 · 121 阅读 · 0 评论 -
Codeforces Round #701 (Div. 2) 1485 A.Add and Divide
题目地址题目大意有a和b两个数,可以进行两个操作:a = a / b,b = b+1。找出最小的使a=0的操作数。思路由题可知,a和b的最大值为10^9,考虑最极端的情况:a = 10^9,b = 2时,a / 2 的操作数为30。数据量小,我们可以考虑将一个范围内的所有操作数全部枚举出来,然后进行比较,最终找出最小操作数。#include <iostream>#include <algorithm>#include <string>using name原创 2021-02-17 13:08:50 · 366 阅读 · 2 评论 -
P2089 烤鸡
题目地址思路如果不会搜索、队列说的就是我 ,可以模拟四进制,并枚举出答案。#include <iostream>#include <string>#include <algorithm>#include <iomanip>using namespace std;int num[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; //调料初始状态int fun[1000000][10];原创 2021-02-17 13:04:44 · 71 阅读 · 0 评论 -
HDU2098
戳这里进入原题目HDU2098把一个偶数拆成两个不同素数的和,有几种拆法呢?输入:输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。输出:对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。输入样例:30260输出样例:3 2思路该题输入范围不大,我们可以将一个长度为10001的数组初始化为0,然后将素数脚标的数组赋值为1,最后用暴力法枚举出方案数。注意:格式化输入输出(scanf、printf)比流式输入输出(cin、原创 2021-01-30 12:23:22 · 80 阅读 · 0 评论 -
C++语言中反转字符串的函数strrev(), reverse()
原文章地址:C++语言中反转字符串的函数strrev(), reverse() ,作者:王陸(侵删)1.使用string.h中的strrev函数1 #include<stdio.h>2 #include<string.h>3 int main()4 {5 char s[]="hello";6 strrev(s);7 puts(s);8 return 0;9 }2.使用algorithm中的reverse函数 1 #incl转载 2021-01-26 22:54:38 · 1352 阅读 · 0 评论 -
C++ string库函数详解
声明:这篇博客是转载的,侵删,原作者:John_yan15博客C++ string库函数详解1. 运算符重载+、+= 连接字符串= 字符串赋值>、>=、<、<= 字符串比较(例如a < b, aa < ab)==、!= 比较字符串<<、>> 输出、输入字符串注意:使用重载的运算符 + 时,必须保证前两个操作数至少有一个为 s转载 2021-01-11 21:10:10 · 2627 阅读 · 0 评论