
算法竞赛入门到进阶刷题
MokylinJay
Hello World!
展开
-
三角形
思路:在给定数组中选定三根木棍组成三角形,书上给出的解题思路为三重循环暴力查找符合条件的三根木棍。其中要注意的点有:要保证不要选到重复的木棍,即 k > j > i判断组成三角形的条件,即任意两边之和大于第三边#include <algorithm>#include <iostream>#include <stdio.h>#define MAX_N 100using namespace std;int n, a[MAX_N];vo原创 2020-12-29 20:24:27 · 174 阅读 · 0 评论 -
HDU 1062 Text Reverse
题目地址Problem DescriptionIgnatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.InputThe input contains several test cases. The first line of the input原创 2020-09-19 09:29:15 · 116 阅读 · 0 评论 -
HDU 4841 圆桌问题
题目地址Problem Description圆桌上围坐着2n个人。其中n个人是好人,另外n个人是坏人。如果从第一个人开始数数,数到第m个人,则立即处死该人;然后从被处死的人之后开始数数,再将数到的第m个人处死……依此方法不断处死围坐在圆桌上的人。试问预先应如何安排这些好人与坏人的座位,能使得在处死n个人之后,圆桌上围坐的剩余的n个人全是好人。原创 2020-09-16 23:01:31 · 149 阅读 · 0 评论