You are given two positive integers aa and bb . In one move, you can change aa in the following way: Choose any positive odd integer xx (x>0x>0 ) and replace aa with a+xa+x ; choose any positive even integer yy (y>0y>0 ) and replace aa with
Peter and his friends are on holiday, so they have decided to make a trip by car to know the north of Spain. They are seven people and they think that two cars are enough for their luggage. It’s time to leave . . . and a heap of suitcases are awaiting
题目 传送门 思路 对条件进行一下变形 如果对于\(i,j\)两个人,如果\(i\)选择\(x_i\),则必定有关系 \(x_i+y_j<y_i+x_j\) 之后移下项 \(x_i-x_j<y_i-y_j\) 之后排序算贡献就可以了 代码 #include<iostream> #include<vector> #include<algorithm> using namespace std; #define int lo
水题... 按照之前的做法,把支不支持的分为两类,各与S,T连边,互为朋友直接连边....然后直接跑最小割即可 正确性下显然.因为割边等价于把任意一个朋友变为相反...(解决了矛盾.....) 就没了... 哦,注意把朋友间连边(这个连的是双向边!)
现在是濒临崩溃状态的我 一上午做的所有题都是水题可它就是过不去啊我有啥子办法 明明算法如此简单 害 还是写一点小总结: 1.学到了内存计算方法 2.try catch参见try except 3.模拟的边界问题要注意 害
题目地址 https://www.luogu.com.cn/problem/P1001 解答 阅读理解题。 OS:是谁在水题?是我是我就是我。 #include <iostream> //----------------------- using namespace std; //----------------------- int main() { long a,b; cin>>a>>b; cout<<a+b; return 0
A. Eating Souptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output The three friends, Kuro, Shiro, and Katie, met up again! It’s time for a party… What the cats do when they unite? Right, the
今天的我自闭了~~~ 今天上午讲了数据结构,栈,单调栈,笛卡尔数,队列,常用STL,线段树,Segment Beats,以及涉及的一些题型,听得好懵,除了会的,一律的都听不懂,还是先熟悉一下这个东西,留给以后学吧。(蒟蒻的我抱着这个想法) 下午测试,五个小时,写了两个水题,完全不是什么不理想,就只能写两个
题目描述 设有nn个正整数(n≤20)(n≤20),将它们联接成一排,组成一个最大的多位整数。 例如:n=3n=3时,33个整数1313,312312,343343联接成的最大整数为:3433121334331213 又如:n=4n=4时,44个整数77,1313,44,246246联接成的最大整数为:74246137424613 输入 # 3 13 312 343 输出 #
A - Blackjack (水题) 题目链接 大致思路: 水题 B - Palindrome-philia (水题) 题目链接 大致思路: 由于整个串是回文串,只要判断前一半和后一半有多少个不同即可 C - HonestOrUnkind2 (暴力) 题目链接 大致思路: \(N\) 只有15,直接枚举出所有的情况 \(2^N\) 种,对每一种方案判断合法
1.已知含有10个整数的查找表如下:(9,13,15,7,45,32,56,89,60,36),从键盘上输入一个整数,用顺序查找的方法在查找表中查找该整数。若存在,输出该元素的下标值,否则,输出-1。 Input 输入一个整数 Output 如找到输出被找元素的下标值,否则,输出-1 Sample Input 56 Sample Output index=7AC代码: 1
A. Math Problem Your math teacher gave you the following problem: There are n segments on the x-axis, [l1;r1],[l2;r2],…,[ln;rn]. The segment [l;r] includes the bounds, i.e. it is a set of such x that l≤x≤r. The length of the segment [l;r] is equal to r−l.
其实这篇https://www.cnblogs.com/victorique/p/8560656.html写得很完整了,但是为了加深自己的印象,就自己写一篇吧。 网络流的练习我用了传说中的网络流24题,我把题目都看了一遍,发现一个问题,有些题好像真的是为了网络流而搞网络流的做法出来,导致题目的可做性不强,虽然如此,但是除了
题目 传送门 题目 与其直接求答案 不如直接算当前的数作为最大值的贡献,与这个数作为最小值的贡献 代码 #include<iostream> #include<algorithm> using namespace std; #define int long long const int mod=1e9+7; int n; int a[1000005]; long long ans; long long qkpow(int a,
A. Two Rival Students There are
题目背景 小明是汉东省政法大学附属中学的一名学生,他每天都要骑自行车往返于家和学校。为了能尽可能充足地睡眠,他希望能够预计自己上学所需要的时间。他上学需要经过数段道路,相邻两段道路之间设有至多一盏红绿灯。 京州市的红绿灯是这样工作的:每盏红绿灯有红、黄、绿三盏灯
题目分析:对于输入的数据分三条,选出每条中最大值记录下来,按照题目要求算出最大可能的获利即可 1 #include<iostream> 2 using namespace std; 3 4 double k[3]; //k数组存放每次的三个倍率 5 int p[3]; //存放三次选择的下标 6 char ans[3] = {'W', 'T'
题目分析:用一个字符串输入之后遍历每一位求和后,不断%10获取最后一位存储下来,逆序用对应的英文单词输出(注意输入为0的情况) 1 #include<iostream> 2 #include<string> 3 using namespace std; 4 5 string a[10] = {"zero", "one", "two", "three", "four", &quo
呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体.Harry已经将他所会的所有咒语都列成了一个表
整场考试心态是崩的,T1水题打了半天表,将近两个小时才A掉。 T2数据结构题想麻烦了,码了5.1K(数据结构选手) 等到最后一刻我发现T3水题,生无可恋.jpg 然后吃屎地在暴力中输出了下标,(%%%出题人精心构造样例) T2 拆柿子即可 T3 随便优化一下 $O(n^2logn)$
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4847 题意: Now, Doge wants to know how many words “doge” are there in a given article. Would you like to help Doge solve this problem? 思路: 暴力完事 代码: #include <iostream> #include <cstdio> #include <
题目: 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 示例 3: 输入:
点击比赛链接:https://ac.nowcoder.com/acm/contest/1087#question 思路: 直接看末尾是否有AK即可。 AC: 1 #include<iostream> 2 #include<cstdio> 3 #include<ctime> 4 #include<cstring> 5 #include<cstdlib> 6 #include<cmath> 7 #inclu
枚举每一列的位置,求哪个字符出现的次数最多 #include<iostream> #include<string> #include<map> #include<cstdio> #include<vector> #include<algorithm> #include<assert.h> #include<cstring> using namespace std; #define _for(i, a, b)
题目:POJ-2503 题意:字典中的单词对于不同的类别,求给定的单词的类别 题解:直接hash,但是输入真的很毒瘤。。。。 代码: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<map> #define P 233 #define N 100005 #define LL l