题面
题意
给定一个方程,求出 x 的最小正整数解,如果不存在,则输出 -1 。
分类 解题报告 下的文章
Garden
Time Limit: 1000MS Memory Limit: 65536KDescription
There are n flowerpots in Daniel's garden. These flowerpots are placed in n positions, and these n positions are numbered from 1 to n. Each flower is assigned an aesthetic value. The aesthetic values vary during different time of a day and different seasons of a year. Naughty Daniel is a happy and hardworking gardener who takes pleasure in exchanging the position of the flowerpots.
Friends of Daniel are great fans of his miniature gardens. Before they visit Daniel's home, they will take their old-fashioned cameras which are unable to adjust the focus so that it can give a shot of exactly k consecutive flowerpots. Daniel hopes his friends enjoy themselves, but he doesn't want his friend to see all of his flowers due to some secret reasons, so he guides his friends to the best place to catch the most beautiful view in the interval [x, y], that is to say, to maximize the sum of the aesthetics values of the k flowerpots taken in one camera shot when they are only allow to see the flowerpots between position x to position y.
There are m operations or queries are given in form of (p, x, y), here p = 0, 1 or 2. The meanings of different value of p are shown below.
- p=0 settheaestheticvalueofthepotinpositionxasy.(1<=x<=n;-100<= y <= 100)
- p = 1 exchange the pot in position x and the pot in position y. (1 <= x, y <= n; x might equal to y)
- p = 2 print the maximum sum of aesthetics values of one camera shot in interval [x, y]. (1 <= x <= y <= n; We guarantee that y-x+1>=k)
Input
There are multiple test cases.
The first line of the input file contains only one integer indicates the number of test cases.
For each test case, the first line contains three integers: n, m, k (1 <= k <= n <= 200,000; 0 <= m <= 200,000).
The second line contains n integers indicates the initial aesthetic values of flowers from position 1 to position n. Some flowers are sick, so their aesthetic values are negative integers. The aesthetic values range from -100 to 100. (Notice: The number of position is assigned 1 to n from left to right.)
In the next m lines, each line contains a triple (p, x, y). The meaning of triples is mentioned above.Output
For each query with p = 2, print the maximum sum of the aesthetics values in oneshot in interval [x, y].Sample Input
1
5 7 3
-1 2 -4 6 1
2 1 5
2 1 3
1 2 1
2 1 5
2 1 4
0 2 4
2 1 5Sample Output
4
-3
3
1
6
两个人在一个有 n×m 个房间的健身房内健身,每个房间都有一个锻炼可消耗的卡路里数。一个人从 a1 一路锻炼到 an ,每次只能从 ai 移动到 ai+1 或 ai;另一个从 an 一路锻炼到 a1,每次只能从 ai 移动到 ai 或 ai-1 。每在一个房间锻炼可以消耗对应的卡路里数,两个人必须在中间的某一个房间碰面且只能碰面一次,这个房间不计算卡路里数。求两人如何走,能使两人总计消耗卡路里数最大。
Fighting_小银考呀考不过四级
Time Limit: 1000MS Memory Limit: 65536KBProblem Description
四级考试已经过去好几个星期了,但是小银还是对自己的英语水平担心不已。
小银打算好好学习英语,争取下次四级考试和小学弟小学妹一起拿下它!
四级考试的时候,监考老师会按考号分配固定的座位,但唯一不变的是每两个人之间肯定至少会留下两个空座位,原因相信大家都懂得。
那么问题来了,我们现在只关注教室里的一排座位,假设每排有n个座位,小银想知道这一排至少坐一个人的前提下,一共有多少种坐法。Input
多组输入。
第一行输入整数n,代表教室里这一排的座位数目。(1 <= n <= 45)Output
输出种类数目。输入输出各占一行,保证数据合法。Example Input
1
3
5Example Output
1
3
8Hint
Author
Casithy