
oj
文章平均质量分 68
guojiaqi007
这个作者很懒,什么都没留下…
展开
-
九度 oj 题目1548:平面上的点
http://ac.jobdu.com/problem.php?pid=1548code from http://www.lai18.com/content/477808.html#include #include #include using namespace std;#define ms(x,y) memset(x,y,sizeof(x))#define i转载 2017-03-13 23:01:49 · 427 阅读 · 0 评论 -
九度 oj 题目1140:八皇后
http://ac.jobdu.com/problem.php?pid=1140#include #include static int map[8][8];static int pos[8];static int ans[92],cn;void deploy(int i, int j, int v){ int _i=i,_j=j; while(_i<8) m原创 2017-01-25 16:43:30 · 393 阅读 · 0 评论 -
九度 oj 题目1131:合唱队形
http://ac.jobdu.com/problem.php?pid=1131两次动态规划 最长子序列#include #include #include int main(){ //freopen("in/1131.in","r", stdin); int height[102],n; int dpl[101],dph[101],i原创 2017-01-24 16:53:49 · 384 阅读 · 0 评论 -
九度 oj 题目1130:日志排序
http://ac.jobdu.com/problem.php?pid=1130参考了 http://www.cnblogs.com/jasonJie/p/5740646.html#include #include #include typedef struct date{ int year,month,day; friend bool oper转载 2017-01-24 16:07:19 · 386 阅读 · 0 评论 -
九度 oj 题目1119:Integer Inquiry
http://ac.jobdu.com/problem.php?pid=1119#include #include #include int main(){ //freopen("in/1119.in","r",stdin); int res[200],num[102],rlen,len,c,x; char str[102]; memset原创 2017-01-23 15:53:53 · 266 阅读 · 0 评论 -
九度 oj 题目1147:Jugs
http://ac.jobdu.com/problem.php?pid=1147好像 九度的oj judge 有问题,不对的code也可以过。建议使用 UVa的测试https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=512自己谢了bfs原创 2017-01-23 11:25:38 · 320 阅读 · 0 评论 -
九度 oj 题目1149:子串计算
http://ac.jobdu.com/problem.php?pid=1149#include #include #include typedef struct item{ char s[102]; int times; bool friend operator < (struct item a, struct item b){原创 2017-01-21 18:59:34 · 236 阅读 · 0 评论 -
九度 oj 题目1161:Repeater
http://ac.jobdu.com/problem.php?pid=1161#include static int N,Q; static char Map[3001][3001];static char Template[6][6];int myPow(int n,int q){ int m = 1; while(q--){ m*=n;原创 2017-01-21 17:15:26 · 577 阅读 · 0 评论 -
所有组合, 所有排列的模板(从n个数中选m个数的所有组合和所有排列)
参考了 http://www.acmerblog.com/combinations-of-r-elements-6059.html#include #include void combine(int arr[], int data[], int start, int end,int idx,int r){ // has found r elements if(原创 2017-01-17 11:07:33 · 511 阅读 · 0 评论 -
九度 oj 题目1159:坠落的蚂蚁
http://ac.jobdu.com/problem.php?pid=1159#include #include typedef struct ant{ int pos,dir; bool friend operator < (struct ant a, struct ant b){ return a.pos < b.pos; }原创 2017-01-21 13:52:19 · 537 阅读 · 0 评论 -
九度 oj 题目1154:Jungle Roads
http://ac.jobdu.com/problem.php?pid=1154最小生成树:堆+并查集#include #include typedef struct edge{ int l,r,w; bool friend operator < (struct edge a, struct edge b){ return a.w > b.w;原创 2017-01-21 11:02:28 · 306 阅读 · 0 评论 -
九度 oj 题目1040:Prime Number
http://ac.jobdu.com/problem.php?pid=1040两种方法:#include #include #include #define MAXN 2000000static int primes[10001],nPrimes;static bool mark[MAXN];void init0(){ memset(mark,true,转载 2017-02-06 11:37:05 · 302 阅读 · 0 评论 -
九度oj 题目1457:非常可乐
http://ac.jobdu.com/problem.php?pid=1457#include #include #include #include using namespace std;bool visit[101][101][101];int n, m, s;typedef struct status { int a,b,c; int steps; void原创 2017-02-28 22:05:31 · 505 阅读 · 0 评论 -
九度 oj 题目1142:Biorhythms
http://ac.jobdu.com/problem.php?pid=1142此题利用了中国剩余定理参考了1.http://www.cnblogs.com/My-Sunshine/p/4830388.html2.http://blog.youkuaiyun.com/sinat_30126425/article/details/52154948代码来自于:参考2转载 2017-01-22 15:46:03 · 316 阅读 · 0 评论 -
九度 oj 题目1112:拦截导弹
http://ac.jobdu.com/problem.php?pid=1112#include #include #include int main(){ //freopen("in/1112.in","r",stdin); int a[26], dp[26],n; while(scanf("%d",&n)!=EOF){ for原创 2017-01-27 13:28:59 · 322 阅读 · 0 评论 -
九度 oj 题目1114:神奇的口袋
http://ac.jobdu.com/problem.php?pid=1114#include int main(){ //freopen("in/1114.in","r",stdin); int n,dp[41],a[41]; while(scanf("%d",&n) !=EOF){ for (int i = 1; i <=n;原创 2017-01-27 14:34:25 · 558 阅读 · 0 评论 -
九度 oj 题目1072:有多少不同的面值组合?
http://ac.jobdu.com/problem.php?pid=1072#include const int n = 15;const int v = 8 * 5 + 10 * 4 + 18 * 6;const int a[n+1] = { 0,8,8,8,8,8,10,10,10,10,18,18,18,18,18,18 };#define rep(i,j,k) fo原创 2017-03-04 14:43:40 · 292 阅读 · 0 评论 -
计算器--可以计算合理表达是的计算器,包括+-×/()
参考了1.王道的机试复试书#include #include #include static int p[][7] = { /* $ + - * % ( )*/ /*$ */ { 0,-1,-1,-1,-1,-1,-2}, /*+*/ { 1, 1, 1,-1,-1,-1, 1}, /*-*/ { 1, 1,转载 2017-01-22 09:56:25 · 249 阅读 · 0 评论 -
九度 oj 题目1037:Powerful Calculator
http://ac.jobdu.com/problem.php?pid=1037参考了1.王道机试指南#include #include #include #include using namespace std;static const int maxn = 200;static const int ten[4] = {1,10,100,1000}; t原创 2017-02-07 09:51:15 · 483 阅读 · 0 评论 -
九度 oj 题目1549:货币问题
http://ac.jobdu.com/problem.php?pid=1549参考了http://www.voidcn.com/blog/newchan/article/p-4594278.html贪心,用大面值肯定比用小面值 张数少#include #include #include using namespace std;#define ms(x,y) memset(x,转载 2017-03-08 23:07:47 · 354 阅读 · 0 评论 -
九度 oj 题目1550:分糖果
http://ac.jobdu.com/problem.php?pid=1550默认给最少“1”, 如果a[i] > a[i-1], 比前面多给一个。如果 a[i] 参考了http://blog.youkuaiyun.com/xiexingshishu/article/details/20319825#include #include using namespace std;#def转载 2017-03-08 22:35:37 · 323 阅读 · 0 评论 -
九度 oj 题目1552:座位问题
http://ac.jobdu.com/problem.php?pid=1552动归,分最后一个是男还是女讨论。注意当总共有0人以男结尾的排列是1种情况。 #include #define inone(i) scanf("%d",&i)const int maxn = 1e3 + 10;int m[maxn], f[maxn], n;void init(){ f[转载 2017-03-08 20:30:49 · 283 阅读 · 0 评论 -
九度 oj 题目1554:区间问题
http://ac.jobdu.com/problem.php?pid=1554copy from http://blog.youkuaiyun.com/u013491262/article/details/21406351把sum[1~i] = sum[i], sum[i] 是以a[i]为最后一个元素的前缀和, Map以前缀和为key, 具有相同的前缀和的idx的vector 为va转载 2017-03-08 16:15:16 · 345 阅读 · 0 评论 -
九度 oj 题目1555:重复子串
http://ac.jobdu.com/problem.php?pid=1555这道题觉得还可以再优化,暂时先水过了。#include #include #include using namespace std;#define rep(i,j,k) for(int i=j;i<=k;i++)string s;int cal(string s){ set uniq;原创 2017-03-08 14:39:46 · 372 阅读 · 0 评论 -
九度 oj 题目1171:C翻转
http://ac.jobdu.com/problem.php?pid=1171#include #include using namespace std;#define rep(i,j,k) for(int i=j;i<=k;i++)#define inone(i) scanf("%d",&i)#define infour(a,b,c,d) scanf("%d%d%d%d"原创 2017-03-04 17:50:16 · 391 阅读 · 0 评论 -
九度 oj 题目1010:A + B
http://ac.jobdu.com/problem.php?pid=1010#include #include #include #include #include using namespace std;map Map;int get(string s){ string a; istringstream is(s); int res = 0; while原创 2017-03-08 14:00:09 · 284 阅读 · 0 评论 -
九度 oj 题目1009:二叉搜索树
http://ac.jobdu.com/problem.php?pid=1009#include #include #include using namespace std;#define rep(i,j,k) for(int i=j;i<=k;i++)#define inone(i) scanf("%d",&i)//typedef struct nd { int v;原创 2017-03-08 12:36:10 · 330 阅读 · 0 评论 -
九度 oj 题目1008:最短路径问题
http://ac.jobdu.com/problem.php?pid=1008这道题告诉我们 INT_MAX, 慎用,dijkstra 有时加溢出了,你都不知道#include //#include #include using namespace std;#define rep(i,j,k) for(int i=j;i<=k;i++)#define inone(i)原创 2017-03-08 11:29:10 · 388 阅读 · 0 评论 -
九度 oj 题目1006:ZOJ问题
http://ac.jobdu.com/problem.php?pid=1006#include #include #include using namespace std;#define rep(i,j,k) for(int i=j;i<=k;i++)bool ac(string s){ //cout << s << endl; int len = s.size()原创 2017-03-08 10:05:03 · 281 阅读 · 0 评论 -
九度 oj 题目1073:杨辉三角形
http://ac.jobdu.com/problem.php?pid=1073#include #include #define inone(i) scanf("%d",&i)#define rep(i,j,k) for(int i=j;i<=k;i++)const int maxn = 1e6;int n;int dp[2][maxn];int get(int i,原创 2017-03-04 15:23:56 · 283 阅读 · 0 评论 -
九度 oj 题目1084:整数拆分
http://ac.jobdu.com/problem.php?pid=1084照抄了 http://blog.youkuaiyun.com/jdplus/article/details/18839343参考了 http://www.cnblogs.com/yinger/archive/2012/08/17/2644312.html#include int main(){转载 2017-01-15 09:38:38 · 281 阅读 · 0 评论 -
九度 oj 题目1043:Day of Week
http://ac.jobdu.com/problem.php?pid=1043有两种做法:一公式法:如code1。编码简单,但是在九度上不能ac。二比较法:如code2,比较今天和目标时间的差,推算目标时间的星期。code1:#include #include static const char* month [] { "","January", "原创 2017-02-06 14:52:10 · 257 阅读 · 0 评论 -
九度 oj 题目1111:单词替换
http://ac.jobdu.com/problem.php?pid=1111这一题我用了 stl#include #include using namespace std;int main(){ //freopen("in/1111.in","r",stdin); string str,newString, a,b; string::si原创 2017-01-27 13:08:13 · 501 阅读 · 0 评论 -
九度 oj 题目1081:递推数列
http://ac.jobdu.com/problem.php?pid=1081参考了(照抄了)http://blog.youkuaiyun.com/zxasqwedc/article/details/8763967 #include #include #include #define LL long longstatic LL a0,a1,p,q,k; typedef转载 2017-01-15 15:33:58 · 214 阅读 · 0 评论 -
九度 oj 题目1042:Coincidence (LCS)
http://ac.jobdu.com/problem.php?pid=1042#include #include #include int main(){ //freopen("in/1042.in","r",stdin); int dp[101][101],m,n; char a[101],b[101]; while(scanf("%s原创 2017-02-06 13:05:08 · 264 阅读 · 0 评论 -
九度OJ 1437 To Fill or Not to Fill -- 贪心算法
#include #include #include typedef struct gas_station{ double price; int dis; friend bool operator < (struct gas_station a, struct gas_station b){ return a.dis < b.dis;转载 2017-01-12 16:53:40 · 469 阅读 · 0 评论 -
九度 oj 题目1085:求root(N, k)
http://ac.jobdu.com/problem.php?pid=1085refs: 1.http://blog.youkuaiyun.com/JDPlus/article/details/18840577?locationNum=1&fps=12.http://blog.sina.com.cn/s/blog_8619a25801010wcy.htmlCode from转载 2017-01-15 11:39:13 · 233 阅读 · 0 评论 -
九度 oj 题目1087:约数的个数
http://ac.jobdu.com/problem.php?pid=1087照抄了 http://blog.youkuaiyun.com/jdplus/article/details/18353667#include #include int main(){ //freopen("in/1087.in","r",stdin); int n; int转载 2017-01-14 21:15:49 · 232 阅读 · 0 评论 -
九度 oj 题目1096:日期差值
http://ac.jobdu.com/problem.php?pid=1096计算每个日期的总日子,然后相减。#include static int days = 365;static int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 }; int leap(int year){ if(!原创 2017-02-06 09:17:37 · 237 阅读 · 0 评论 -
九度 oj 题目1086:最小花费
http://ac.jobdu.com/problem.php?pid=1086#include #include #include int main(){ //freopen("in/1086.in","r",stdin); long long l1,l2,l3,c1,c2,c3; int A,B; int n=0; int* a;原创 2017-01-14 20:54:25 · 275 阅读 · 0 评论