
杂题
文章平均质量分 66
您还不是尊贵的会员身份
这个作者很懒,什么都没留下…
展开
-
POJ3278 Catch That Cow(BFS) 坑爹的RE
Catch That CowTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 98620 Accepted: 30955DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch原创 2017-10-09 00:00:02 · 247 阅读 · 0 评论 -
简单的动态规划——装箱问题
装箱问题告诉你箱子的容积为多少,告诉你有N件物品和每一件物品的体积,问如何选择物品才能令箱子的剩余容积最小。 搜索递归#include<bits/stdc++.h>using namespace std;int p;int v[40];int n;int dp(int i,int j){ int ans=j; if(i==0) {ans=j;return ans;} else原创 2017-12-20 20:25:06 · 3370 阅读 · 0 评论 -
CodeForces 797A 以及关于质数筛选和质因数分解的一堆东西
k-FactorizationGiven a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n.Input The first line原创 2017-12-05 13:15:13 · 304 阅读 · 0 评论 -
CodeForces - 797B Odd sum
Odd sumYou are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that giv原创 2017-12-05 13:42:23 · 334 阅读 · 0 评论 -
POJ3087 Shuffle'm Up (strcmp;strcpy;strcat)
Shuffle’m UpA common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing原创 2017-12-05 21:57:06 · 139 阅读 · 0 评论 -
M进制转10进制
STL解法#include <bits/stdc++.h>using namespace std;int m;char s[105];int main(){cin>>s>>m;cout<<strtol(s,NULL,m)<<endl;return 0;} #include<iostream>using namespace std;int main(){int a,b,c;原创 2017-12-14 21:01:08 · 405 阅读 · 0 评论 -
gcd算法
手写gcdvoid gcd(int m,int n){ if(n>m) { int tmp=m; m=n; n=tmp; } while(m%n) { int r=m%n; m=n; n=r; } return n;}STLint ans;ans=_gcd原创 2017-12-14 21:09:37 · 387 阅读 · 0 评论 -
快速幂
快速幂思想:将指数二进制展开 复杂度:log n//quick_pow#include<iostream>#include<cstdio>using namespace std;int quick_pow(long long a,long long b){ long long ans=1,base=2; while(b!=0) { if(b&1)//从右至左二进最后一原创 2017-12-25 21:06:16 · 176 阅读 · 0 评论 -
Codeforces Round #451 (Div. 2) Proper Nutrition 暴力枚举
Proper NutritionVasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer原创 2017-12-18 08:34:53 · 209 阅读 · 0 评论 -
Codeforces Round #459 (Div. 2) A. Eleven
A. Eleventime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEleven wants to choose a new name for herself. As原创 2018-01-30 21:56:34 · 223 阅读 · 0 评论 -
Codeforces Round #459 (Div. 2) B. Radio Station
B. Radio Stationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs the guys fried the radio station facili原创 2018-01-30 22:22:55 · 194 阅读 · 0 评论 -
Codeforces Round #460 (Div. 2) A. Supermarket
A. SupermarketWe often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk w原创 2018-02-01 00:51:28 · 247 阅读 · 0 评论 -
Codeforces Round #460 (Div. 2) B. Perfect Number
B. Perfect NumberWe consider a positive integer perfect, if and only if the sum of its digits is exactly 10. Given a positive integer k, your task is to find the k-th smallest perfect positive integ原创 2018-02-01 00:54:11 · 227 阅读 · 0 评论 -
CodeForces - 895A Pizza Separation 简单枚举 区间
Pizza SeparationStudents Vasya and Petya are studying at the BSU (Byteland State University). At one of the breaks they decided to order a pizza. In this problem pizza is a circle of some radius. The p原创 2017-12-03 17:54:22 · 270 阅读 · 0 评论 -
CodeForces - 272B Dima and Sequence 函数/思维
Dima and Sequencetime limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Dima got into number sequences. Now he’s got sequence a1, a2, …, an, co原创 2017-12-03 17:36:27 · 302 阅读 · 0 评论 -
回文数和回文词
判断是否是回文数bool isok(int x){ int tmp=x; int sum=0; while(tmp) { sum=sum*10+tmp%10; tmp/=10; } return tmp=x;}找出偶数长度回文数int num(){ for(int i=1;i<=10000;i++)原创 2017-12-10 23:25:52 · 264 阅读 · 0 评论 -
hdoj1299 还是A+B
hdoj1299 还是A+BProblem Description 读入两个小于10000的正整数A和B,计算A+B。需要注意的是:如果A和B的末尾K(不超过8)位数字相同,请直接输出-1。Input 测试输入包含若干测试用例,每个测试用例占一行,格式为”A B K”,相邻两数字有一个空格间隔。当A和B同时为0时输入结束,相应的结果不要输出。Output 对每个测试用例输出1行,即A+B的值或原创 2017-09-29 23:01:02 · 341 阅读 · 0 评论 -
最简单的BFS入门题目——迷宫的最短路径
迷宫的最短路径 给定一个大小为N*M的迷宫。迷宫由通道和墙壁组成,每一步可以向相邻的上下左右四格的通道移动。请求出从起点到终点所需的最小步数。如果不能到达,输出“不能走到那里”。(N,M<=50,起点,终点分别用S,G表示)输入样例:N=5,M=5#S###..##.#.###..###..G## 输出:5分析:这是一道BFS模版题,直接要求最短路,没有其他的约束条件 以下是代码原创 2017-10-07 23:44:22 · 6052 阅读 · 2 评论 -
贪心法 部分背包问题 结构体数组 FatMouse' Trade
FatMouse’ Trade题目:FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has N rooms. The i-th room contains原创 2017-10-21 21:36:54 · 424 阅读 · 0 评论 -
二分法-二分查找的应用及三个经典例题
二分法-二分查找应用及例题在ICPC-ACM竞赛中,二分法是一种常用的解题策略,其中二分搜索是应用非常广泛的一种,主要使用的有STL中的binary_search()函数、lower_bound()函数、upper_bound()函数,这些函数一般要配合sort()、unique()函数使用。1. binary_search(begin,end,index):在数组中,若找到index则返回1,找不原创 2017-10-31 22:53:53 · 10697 阅读 · 1 评论 -
HDU-1070 Milk 结构体排序
MilkIgnatius drinks milk everyday, now he is in the supermarket and he wants to choose a bottle of milk. There are many kinds of milk in the supermarket, so Ignatius wants to know which kind of milk is原创 2017-10-31 22:06:23 · 279 阅读 · 0 评论 -
模拟- Combination Lock 开锁游戏
Combination LockScrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he’s earned fair and square, he has to open th原创 2017-11-01 13:50:21 · 610 阅读 · 0 评论 -
CodeForces - 877A 朴素字符串匹配
Alex and broken contestOne day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.B原创 2017-11-21 21:19:56 · 532 阅读 · 0 评论 -
pair排序 线段覆盖 贪心
题目链接 思路非常简单的一道贪心题目,但是在给pair排序的时候出了一点问题 我在使用重载<时发现不起作用,询问学长后才知是pair自带了重载,我定义的被覆盖了,解决方法是用自定义函数#include<bits/stdc++.h>using namespace std;int ans=1;pair<int,int>line[110];bool cmp(const pair<int,int>原创 2017-12-19 21:08:26 · 195 阅读 · 0 评论 -
Codeforces Round #426 (Div. 2) The Useless Toy 数组环
The Useless Toytime limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputWalking through the streets of Marshmallow City, Slastyona have spotted原创 2017-11-22 23:59:45 · 187 阅读 · 0 评论 -
Codeforces Round #460 (Div. 2) C. Seat Arrangements
C. Seat ArrangementsSuppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occ原创 2018-02-01 00:58:33 · 246 阅读 · 0 评论