01 2017 档案

摘要:class Solution { public: int reverse(int x) { int res = 0; while (x != 0) { int t = res * 10 + x % 10; if (t / 10 != res) return 0; res = t; x /= 10; 阅读全文
posted @ 2017-01-30 23:54 王坤1993 阅读(160) 评论(0) 推荐(0)
摘要:class Solution { public: string convert(string s, int nRows) { if (nRows <= 1) return s; string res = ""; int size = 2 * nRows - 2; for (int i = 0; i 阅读全文
posted @ 2017-01-29 20:24 王坤1993 阅读(243) 评论(0) 推荐(0)
摘要:// Time complexity O(n*n) class Solution { public: string longestPalindrome(string s) { int startIdx = 0, left = 0, right = 0, len = 0; for (int i = 0 阅读全文
posted @ 2017-01-29 20:20 王坤1993 阅读(148) 评论(0) 推荐(0)
摘要:class Solution { public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { int total = nums1.size() + nums2.size(); if (total % 阅读全文
posted @ 2017-01-29 20:19 王坤1993 阅读(140) 评论(0) 推荐(0)
摘要:class Solution { public: int lengthOfLongestSubstring(string s) { int m[256] = {0}, res = 0, left = 0; for (int i = 0; i < s.size(); ++i) { if (m[s[i] 阅读全文
posted @ 2017-01-29 20:18 王坤1993 阅读(131) 评论(0) 推荐(0)
摘要:public class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode dummy = new ListNode(-1); ListNode cur = dummy; int carry = 阅读全文
posted @ 2017-01-26 23:54 王坤1993 阅读(157) 评论(0) 推荐(0)
摘要: public class Solution { public int[] twoSum(int[] numbers, int target) { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); int[] 阅读全文
posted @ 2017-01-26 00:03 王坤1993 阅读(146) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; __int64 gcd(__int64 a,__int64 b) { return b?gcd(b,a%b):a; } __int64 lcm(__int64 a,__int64 b) { return a/gcd(a, 阅读全文
posted @ 2017-01-25 00:14 王坤1993 阅读(146) 评论(0) 推荐(0)
摘要:#include <stdio.h> int calc(int a, int b) { if(a==0 || a==1 || a==5 || a==6) return a; if(a==2) { if(b%4==1) return 2; if(b%4==2) return 4; if(b%4==3) 阅读全文
posted @ 2017-01-25 00:13 王坤1993 阅读(185) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main() { int k, a, i, flag; while(~scanf("%d", &k)) { for(i=0; i<66; i++) { if((18+k*i)%65==0) break; } if(i<66) printf("%d\n", 阅读全文
posted @ 2017-01-25 00:13 王坤1993 阅读(150) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; int main() { int n,m,a,sum=0; while(cin>>n) { while (n--) { cin>>m; sum=0; while (m--) { cin>>a; sum=sum+a; } 阅读全文
posted @ 2017-01-25 00:12 王坤1993 阅读(236) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; int main() { int b,a; while(cin>>a>>b) { cout<<a+b<<endl<<endl; } return 0; } 阅读全文
posted @ 2017-01-25 00:11 王坤1993 阅读(185) 评论(0) 推荐(0)
摘要:#include<iostream>using namespace std;int main(){ int n; while(cin>>n){ int sum=0; int i,m; for(i=1;i<=n;++i){ cin>>m; sum+=m; } cout<<sum<<endl; } re 阅读全文
posted @ 2017-01-25 00:09 王坤1993 阅读(233) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; int main() { int n,m,a,sum=0; while(cin>>n) { while (n--) { cin>>m; sum=0; while(m--) { cin>>a; sum=sum+a; } 阅读全文
posted @ 2017-01-25 00:08 王坤1993 阅读(191) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; int main() { int n,a,sum=0; while(cin>>n&&n!=0) { while (n--) { cin>>a; sum=sum+a; } cout<<sum<<endl; sum=0; 阅读全文
posted @ 2017-01-25 00:07 王坤1993 阅读(212) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int a,b; while(scanf("%d%d",&a,&b)==2) { if(a==0&&b==0) break; else printf("%d\n",a+b); } return 0; } 阅读全文
posted @ 2017-01-25 00:05 王坤1993 阅读(153) 评论(0) 推荐(0)
摘要:#include<iostream>using namespace std;int main(){ int n; cin>>n; while(n--){ int a,b; cin>>a>>b; cout<<a+b<<endl; } return 0;} 阅读全文
posted @ 2017-01-23 20:04 王坤1993 阅读(185) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; int main() { int n,m,s; while(cin>>n>>m) { s=n+m; cout<<s<<endl; } return 0; } 阅读全文
posted @ 2017-01-22 23:34 王坤1993 阅读(194) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <string.h> int main() { char s[10000]; int len; int cnt = 0; while(~scanf("%s",s)) { if(!strcmp(s,"<br>")) { cnt = 0; prin 阅读全文
posted @ 2017-01-22 23:32 王坤1993 阅读(186) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <string.h> int main() { int d[1001], ans[1001]; int n, i, j, flag, rst; while(~scanf("%d", &n) && n) { for(i=0; i<n; i++) 阅读全文
posted @ 2017-01-22 23:31 王坤1993 阅读(126) 评论(0) 推荐(0)
摘要:#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h> 阅读全文
posted @ 2017-01-22 23:27 王坤1993 阅读(182) 评论(0) 推荐(0)
摘要:#include <iostream> #include <cstring> using namespace std; int n[3],a[9000],b[9000],i,j,k,last,last2; int v[3]={1,2,5}; int main() { while ((cin>>n[0 阅读全文
posted @ 2017-01-22 23:26 王坤1993 阅读(149) 评论(0) 推荐(0)
摘要:#include<iostream> #include<algorithm> using namespace std; #define N 101 struct node { int score; //学生分数 int num; //学生做出的题目数目 char time[10]; //花费时间 } 阅读全文
posted @ 2017-01-22 23:24 王坤1993 阅读(254) 评论(0) 推荐(0)
摘要:#include"stdio.h" #include"string.h" #define N 305 int mark[N],link[N],map[N][N],p; int find(int a) //匈牙利算法,二分匹配 { int i; for(i=1;i<=p;i++) { if(!mark 阅读全文
posted @ 2017-01-22 23:22 王坤1993 阅读(146) 评论(0) 推荐(0)
摘要:#include<iostream> #include<stack> #include<string> #include<cctype> using namespace std; #define N 30 struct node { char m; int r,c; } a[N]; string s 阅读全文
posted @ 2017-01-22 23:21 王坤1993 阅读(184) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; int GetMaxNum(int a[],int n) //求最大字段和 { int i,sum=0,maxsum=0; maxsum|=1<<31; for(i=1;i<=n;i++) { sum+=a[i]; if 阅读全文
posted @ 2017-01-22 23:19 王坤1993 阅读(190) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; char s1[105],s2[105]; int val[5][5]={ {5,-1,-2,-1,-3}, {-1,5,-3,-2,-4}, {-2,-3,5,-2,-2}, {-1,-2,-2,5,-1}, {-3, 阅读全文
posted @ 2017-01-22 23:17 王坤1993 阅读(198) 评论(0) 推荐(0)
摘要:#include<cstdio> #include<iostream> #include<cstring> using namespace std; int main(){ int y,m,d; int t; scanf("%d",&t); while(t--){ scanf("%d%d%d",&y 阅读全文
posted @ 2017-01-22 23:15 王坤1993 阅读(191) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int n,k,dp[105][105],a[105][105]; int to[4][2] = {1,0,-1,0,0,1,0,-1}; 阅读全文
posted @ 2017-01-22 23:14 王坤1993 阅读(168) 评论(0) 推荐(0)
摘要:#include<iostream> #include<cmath> using namespace std; struct Point { double x,y; }; double dis_sq(const Point& a,const Point& b) //距离平方 { return (a. 阅读全文
posted @ 2017-01-22 23:13 王坤1993 阅读(304) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; int main() { int cases; int k; cin>>cases; while(cases--) { int y,n; cin>>y>>n; int num=0; for(k=y;;k++) { if( 阅读全文
posted @ 2017-01-21 21:02 王坤1993 阅读(143) 评论(0) 推荐(0)
摘要:#include <map> #include <string.h> #include <iostream> using namespace std; #include<stdio.h> int main() { char s1[20],s2[20],s[3005],s3[20],c,a[100]; 阅读全文
posted @ 2017-01-21 21:00 王坤1993 阅读(160) 评论(0) 推荐(0)
摘要:#include <iostream> #include <string> #include <cstring> #include <stack> #include <algorithm> using namespace std; const int inf = 1<<30; struct node 阅读全文
posted @ 2017-01-21 20:56 王坤1993 阅读(162) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read(char p[]) { getchar(); gets(tmp); while(gets(tmp)) { if(strcmp 阅读全文
posted @ 2017-01-21 20:54 王坤1993 阅读(255) 评论(0) 推荐(0)
摘要:#include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; class Data { public: int Etime; int x, y; int count; }; 阅读全文
posted @ 2017-01-21 20:53 王坤1993 阅读(223) 评论(0) 推荐(0)
摘要:#include <iostream> #include <stdio.h> using namespace std; int main() { int t; double x1,y1,x2,y2,x3,y3,a,k,s; cin>>t; while(t--) { cin>>x1>>y1>>x2>> 阅读全文
posted @ 2017-01-21 20:51 王坤1993 阅读(145) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h>struct milk{ char brand[128]; int price; int volume; double value;}a[100];int main(void){ int i,t,n,d; struct mil 阅读全文
posted @ 2017-01-21 20:50 王坤1993 阅读(218) 评论(0) 推荐(0)
摘要:#include <iostream> #include <algorithm> #include <cstring> using namespace std; class Data { public: int S, Height; int upl, uph; }; Data Da[100]; in 阅读全文
posted @ 2017-01-20 22:41 王坤1993 阅读(625) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>const int MAXN=1000;int map[MAXN][MAXN];int n;int linker[MAXN];bool used[MAXN];bool dfs(int a){ for(int i=0;i<n;i++ 阅读全文
posted @ 2017-01-20 22:38 王坤1993 阅读(216) 评论(0) 推荐(0)
摘要:#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<queue> using namespace std; #define MAXN 1000007 typedef long long ll; 阅读全文
posted @ 2017-01-20 22:31 王坤1993 阅读(314) 评论(0) 推荐(0)
摘要:#include <cstdlib> #include <cstring> #include <cstdio> using namespace std; char s[1005]; int len, Mp[25] = {1,1,2,6,4,2,2,4,2,8,4,4,8,4,6,8,8,6,8,2} 阅读全文
posted @ 2017-01-20 22:28 王坤1993 阅读(200) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main() { int t; double x, y; scanf("%d", &t); for(int i = 1; i <= t; ++i){ scanf("%lf%lf", &x, &y); printf("Property %d: This p 阅读全文
posted @ 2017-01-20 22:27 王坤1993 阅读(143) 评论(0) 推荐(0)
摘要:#include <iostream>#include<iomanip>using namespace std; int main(){ float total_sum=0.0; float money_mon[12]; for(int i=0;i<12;i++) { cin>>money_mon[ 阅读全文
posted @ 2017-01-20 22:22 王坤1993 阅读(132) 评论(0) 推荐(0)
摘要:#include<iostream> #include<string> using namespace std; struct BigReal //高精度实数 { int len; //长度 int num[10000]; int point; //小数点位置 BigReal() { len=1; 阅读全文
posted @ 2017-01-20 22:20 王坤1993 阅读(256) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<string.h> int main() { int i,n,len,j,k,t; char s1[1005],s2[100]; scanf("%d",&n); getchar(); while(n--) { gets(s1); len=strl 阅读全文
posted @ 2017-01-20 22:18 王坤1993 阅读(301) 评论(0) 推荐(0)
摘要:#include <iostream>#include <cstdio>using namespace std;int mod_exp(int a, int b, int c) //快速幂取余a^b%c{ int res, t; res = 1 % c; t = a % c; while (b) { 阅读全文
posted @ 2017-01-20 22:14 王坤1993 阅读(145) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<math.h>int main(){ __int64 cas,b,i,d; double a,m,n,c; scanf("%I64d",&cas); for(i=1;i<=cas;i++) { scanf("%lf",&n); a=n*log10( 阅读全文
posted @ 2017-01-20 22:12 王坤1993 阅读(131) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <string.h> #define MAXN 120005 int main() { int num[7]; int T = 0; while (scanf("%d %d %d %d %d %d", &num[1], &num[2], &nu 阅读全文
posted @ 2017-01-20 22:11 王坤1993 阅读(193) 评论(0) 推荐(0)
摘要:#include<iostream> #include<string> using namespace std; int const N = 4; int map[N] = {2,3,5,7}; int findMin(int arr[], bool flag[], int len) { int m 阅读全文
posted @ 2017-01-20 22:08 王坤1993 阅读(119) 评论(0) 推荐(0)
摘要:#include <iostream> #include <string> #include <cstring> using namespace std; int dir[4][2]={{0,-1},{0,1},{-1,0},{1,0}}; int mat[20][20],tar[20][20],t 阅读全文
posted @ 2017-01-20 00:22 王坤1993 阅读(276) 评论(0) 推荐(0)
摘要:#include <cstdio> void main(){ double length; double l[300]; l[1] = 1.0/2; int i; for (i = 2;; ++i) { l[i] = l[i-1] + 1.0/(i+1); if (l[i] >= 5.20) bre 阅读全文
posted @ 2017-01-19 00:06 王坤1993 阅读(200) 评论(0) 推荐(0)
摘要:#include<iostream> #include<iomanip> #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<cmath> #include<map> #include<s 阅读全文
posted @ 2017-01-18 23:49 王坤1993 阅读(232) 评论(0) 推荐(0)
摘要:/* 【题意】 给定一棵树,标记一节点,则与该节点所连的边都被标记,问最少需要标记多少个节点使得所有边都被标记; 或者说给定一个树型城堡,在交叉路口放一个士兵,则与该路口相连的路都被守住, 问最少需要派遣多少个士兵来守住这个城堡 dp[father].yes= ( min(dp[child].yes 阅读全文
posted @ 2017-01-18 22:13 王坤1993 阅读(153) 评论(0) 推荐(0)
摘要:#include<iostream> #include<algorithm> using namespace std; bool cmp(int a,int b) { return a>b; //从大到小排序 } int a[30],m; char s[1005]; int huffman() { 阅读全文
posted @ 2017-01-18 22:11 王坤1993 阅读(164) 评论(0) 推荐(0)
摘要:#include <iostream>#include<algorithm>#include<queue>#include<stack>#include<cmath>#include<string.h>#include<stdio.h>#include<stdlib.h>using namespac 阅读全文
posted @ 2017-01-18 22:08 王坤1993 阅读(102) 评论(0) 推荐(0)
摘要:#include<iostream> #include<algorithm> using namespace std; struct SIZE { int l; int w; }sticks[5005]; int flag[5005]; bool cmp(const SIZE &a,const SI 阅读全文
posted @ 2017-01-18 00:14 王坤1993 阅读(132) 评论(0) 推荐(0)
摘要:#include <cstdio> #include <algorithm> using namespace std; #define SIZE 205 struct Data_Type { int from, to; bool flag; }moving[SIZE]; bool Cmp(const 阅读全文
posted @ 2017-01-16 23:19 王坤1993 阅读(193) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int n,u,d; while(scanf("%d%d%d",&n,&u,&d),n) { int t=(n-u)/(u-d); if(t*(u-d)<(n-u)) t++; t*=2; t++; printf("%d\n",t); } r 阅读全文
posted @ 2017-01-16 23:17 王坤1993 阅读(149) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>#include<iostream>using namespace std;int main(){ //freopen("test.in","r",stdin); //freopen("test.out","w",stdout); 阅读全文
posted @ 2017-01-16 23:16 王坤1993 阅读(102) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string>#include<iostream>using namespace std; //高精度加法//只能是两个正数相加string add(string str1,string str2)//高精度加法{ string str; int 阅读全文
posted @ 2017-01-16 23:14 王坤1993 阅读(133) 评论(0) 推荐(0)
摘要:#include<iostream> #include<cmath> using namespace std; int main() { int T,t=0,m,n; cin>>T; while(T--) { cin>>m>>n; cout<<"Scenario #"<<++t<<":"<<endl 阅读全文
posted @ 2017-01-16 20:37 王坤1993 阅读(147) 评论(0) 推荐(0)
摘要:#include<iostream> using namespace std; int count = 0, n = 0; //判断该ch[x][y]是否可以放置 bool isOk(char **ch, int x, int y){ int i; //向上检索 for (i = x - 1; i 阅读全文
posted @ 2017-01-15 21:55 王坤1993 阅读(111) 评论(0) 推荐(0)
摘要:#include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn=55; int n,m,t,x1,y1,x2,y2; struct node { int x,y; int zb; in 阅读全文
posted @ 2017-01-15 21:54 王坤1993 阅读(273) 评论(0) 推荐(0)
摘要:#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>#include<vector>#include<cmath>#include<map>#include<string>#defi 阅读全文
posted @ 2017-01-15 21:31 王坤1993 阅读(245) 评论(0) 推荐(0)
摘要:#include"stdio.h" #include"stdlib.h" #include"string.h" #define N 10000 int a[N]; int main() { int i,j,n,len; while(scanf("%d",&n)!=-1) { memset(a,0,s 阅读全文
posted @ 2017-01-15 21:25 王坤1993 阅读(101) 评论(0) 推荐(0)
摘要:#include <iostream> #include <string> using namespace std; const int SIZE = 1001; const int BASE = 10; string result[SIZE]; string two("2"); void init 阅读全文
posted @ 2017-01-15 21:22 王坤1993 阅读(298) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<stdlib.h>int a[100];int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;} int main(){ int T,n,i; scanf("%d",&T) 阅读全文
posted @ 2017-01-14 23:44 王坤1993 阅读(230) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>const int MAXN=200;char str[MAXN]; bool isvowel(char c){ if(c=='a'||c=='e'||c=='i'||c=='u'||c=='o') return true; el 阅读全文
posted @ 2017-01-14 23:43 王坤1993 阅读(166) 评论(0) 推荐(0)
摘要:#include <stdio.h> #define P 3.1415927 #define toFeet(x) x/12.0 #define toMiles(x) x/5280.0 int main(){ double diameter;//直径 int revolutions;//转数 doub 阅读全文
posted @ 2017-01-14 23:40 王坤1993 阅读(149) 评论(0) 推荐(0)
摘要:#include <iostream> #include <cstdio> using namespace std; int main() { int a,b,c; while (~scanf("%d%d%d",&a,&b,&c)) { if (a>168&&b>168&&c>168) printf 阅读全文
posted @ 2017-01-14 23:39 王坤1993 阅读(183) 评论(0) 推荐(0)
摘要:#include<stdio.h>int main(){ int n; double d; int num; char h,m1,m2,s1,s2; scanf("%d",&n); scanf("%lf",&d); while(scanf("%d",&num)!=EOF) { printf("%3d 阅读全文
posted @ 2017-01-14 23:37 王坤1993 阅读(162) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>int step,n,m;int a[1010][1010];char map[11][11];void DFS(int x,int y){ while(x>=0&&y>=0&&x<n&&y<m&&map[x][y]!='O') 阅读全文
posted @ 2017-01-14 23:34 王坤1993 阅读(189) 评论(0) 推荐(0)
摘要:#include<stdio.h>const int MAXN=1000;int a[MAXN];int main(){ int n; int i; while(scanf("%d",&n),n) { for(i=0;i<n;i++) scanf("%d",&a[i]); int res=0; wh 阅读全文
posted @ 2017-01-14 23:33 王坤1993 阅读(227) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<string.h> const int MAXN=200; char str[MAXN]; int main() { int x,y; while(scanf("%s",&str)!=EOF) { int len=strlen(str); int 阅读全文
posted @ 2017-01-14 23:32 王坤1993 阅读(148) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; int main() { int a,b,t,i,max; while(cin >> a >> b) { cout << a << " " << b << " "; if(a>b)//大小不确定 { t = a; a 阅读全文
posted @ 2017-01-13 21:09 王坤1993 阅读(178) 评论(0) 推荐(0)
摘要:#include <cstdio> #include <cstdlib> struct element{ int id; double sa; }e[10000]; int cmp(const void *a,const void *b){ return (*(element*)a).sa>(*(e 阅读全文
posted @ 2017-01-13 21:07 王坤1993 阅读(198) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<math.h>void find(int n,int &l,int &r,int &level){ int i; level=1; for(i=1;;i+=2) { if(n-i<=0) { l=(n+1)/2; r=(i-n)/2+1; brea 阅读全文
posted @ 2017-01-13 20:39 王坤1993 阅读(243) 评论(0) 推荐(0)
摘要:#include<iostream>#include<string.h>using namespace std;int main(){ int n,i; int t; int cnt; int result; while(scanf("%d",&n)!=EOF) { cnt=0; for(i=0;i 阅读全文
posted @ 2017-01-13 20:38 王坤1993 阅读(141) 评论(0) 推荐(0)
摘要:#include<stdio.h>#include<string.h>const int MAXN=130;int dp[MAXN][MAXN];//dp[i][j]表示 i 表示成最大的数不超过 j 的方法数int calc(int n,int m){ if(dp[n][m]!=-1) retur 阅读全文
posted @ 2017-01-13 20:37 王坤1993 阅读(147) 评论(0) 推荐(0)
摘要:#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int SIZE=1002; int main() { int n,m; int i,count; int seq[SIZE]; wh 阅读全文
posted @ 2017-01-13 20:35 王坤1993 阅读(223) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <string.h> #include <queue> using namespace std; struct node { int x,y,step; friend bool operator<(node n1,node n2) { retu 阅读全文
posted @ 2017-01-13 20:32 王坤1993 阅读(175) 评论(0) 推荐(0)
摘要:#include<stdio.h>const int MAXN=500010;int a[MAXN],b[MAXN]; //用二分查找的方法找到一个位置,使得num>b[i-1] 并且num<b[i],并用num代替b[i]int Search(int num,int low,int high){ 阅读全文
posted @ 2017-01-13 20:29 王坤1993 阅读(184) 评论(0) 推荐(0)
摘要:#include <cstdio>#include <iostream>const int MAX = 1000005; using namespace std; int num[MAX], pre_max[MAX]; inline int max(int a, int b){ return a > 阅读全文
posted @ 2017-01-11 23:35 王坤1993 阅读(169) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h>#define BASE 10000#define PFMT "%04d"#define MAX 105 void print_bn(int*a, int l){ int i; for(i=l-1;i>0;i--)if(a[i 阅读全文
posted @ 2017-01-11 23:34 王坤1993 阅读(229) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h> int main(void){ int n,i,j,k,l; char o1[10],o2[10],s[10],h[20]; while(scanf("%d %s %s", &n, o1, o2)!=EOF) { memse 阅读全文
posted @ 2017-01-11 23:32 王坤1993 阅读(169) 评论(0) 推荐(0)
摘要:#include <stdio.h> int fib(int m){ int n_2=1,n_1=2,n,i; if(m==0)return 1; if(m==1)return 2; for(i=2;i<=m;i++) { n=(n_2+n_1)%3; n_2=n_1; n_1=n; } retur 阅读全文
posted @ 2017-01-11 23:31 王坤1993 阅读(141) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main(void){ int n,i,c; char txt[10001]; scanf("%d", &n); while(n--) { scanf("%s",txt); i=0; while(txt[i++]) { c=1; while(txt[i] 阅读全文
posted @ 2017-01-11 23:29 王坤1993 阅读(219) 评论(0) 推荐(0)
摘要:#include <stdio.h> int gcd(int a, int b){ int t; while(t=a%b) { a=b; b=t; } return b;} int main(void){ int t,m,n,i,g,lcm; scanf("%d",&t); while(t--) { 阅读全文
posted @ 2017-01-11 23:27 王坤1993 阅读(143) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <math.h> int main(void){ int t,n,i; double sum; scanf("%d", &t); while(t--) { scanf("%d",&n); sum=0; for(i=2;i<=n;i++) sum+ 阅读全文
posted @ 2017-01-11 23:25 王坤1993 阅读(172) 评论(0) 推荐(0)
摘要:#include <stdio.h> int judge(int a, int b, int m){ return (a*a+b*b+m)%(a*b)==0;} int count(int m, int n){ int i,j,c; c=0; for(i=1;i<n;i++) { for(j=i+1 阅读全文
posted @ 2017-01-11 23:20 王坤1993 阅读(180) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h> int prime[38]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1};int visit[21]={0,0,0 阅读全文
posted @ 2017-01-11 23:19 王坤1993 阅读(117) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h> int cmp(void* a, void* b){ return *((char*)a)-*((char*)b);} void solve(int t, char* dic){ int 阅读全文
posted @ 2017-01-11 23:18 王坤1993 阅读(133) 评论(0) 推荐(0)
摘要:#include <stdio.h> int gcd(int a, int b){ int t; while(t=a%b) { a=b; b=t; } return b;} int main(void){ int s,m,i; while(scanf("%d %d", &s, &m)!=EOF) { 阅读全文
posted @ 2017-01-11 23:14 王坤1993 阅读(139) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<string.h> int main() { char num[1000]; int len,sum,i; while(scanf("%s",&num)!=EOF) { len=strlen(num); if(len==1 && num[0]== 阅读全文
posted @ 2017-01-11 21:32 王坤1993 阅读(190) 评论(0) 推荐(0)
摘要:#include<iostream>#include<stdio.h> using namespace std; int jiechen(int n){ int i; int ans=1; for(i=1;i<=n;i++) ans*=i; return ans;} int main(){ int 阅读全文
posted @ 2017-01-11 21:31 王坤1993 阅读(212) 评论(0) 推荐(0)
摘要:/*比较苦逼的树形DP,慢慢来吧!不着急*/#include <iostream>#include <vector>using namespace std;const int SIZE = 105; int roomNumber, trooperNumber;int cost[SIZE], brai 阅读全文
posted @ 2017-01-10 23:51 王坤1993 阅读(375) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <string.h>#include <math.h> int n,m,t;char map[10][10];int flag;int di,dj,wall;int to[4][2] = {{0,-1},{0,1},{-1,0},{1,0}}; 阅读全文
posted @ 2017-01-10 23:46 王坤1993 阅读(120) 评论(0) 推荐(0)
摘要:#include <stdio.h>#include <algorithm>using namespace std; struct Node{ double j,f,p;} node[10000]; int cmp(Node x,Node y){ return x.p>y.p;} int main( 阅读全文
posted @ 2017-01-10 23:39 王坤1993 阅读(262) 评论(0) 推荐(0)
摘要:/**最近点对的问题*/ #include #include #include using namespace std;const int SIZE = 100005;const int L = -1;const int R = 1; typedef struct{int index;double 阅读全文
posted @ 2017-01-10 13:11 王坤1993 阅读(130) 评论(0) 推荐(0)
摘要://c++// #includeusing namespace std;int main(){int n,j,t,start;while (cin >> n,n){start =0;t = 0;while(n--){cin >> j;if (j>start){t += 6*(j-start);}el 阅读全文
posted @ 2017-01-10 13:11 王坤1993 阅读(120) 评论(0) 推荐(0)
摘要:#include<stdio.h>#includeusing namespace std;#define INF 0x7fffffffdouble D;struct node{double l;double r;}s[3][2];node interval(double a,double b)//解 阅读全文
posted @ 2017-01-10 13:10 王坤1993 阅读(142) 评论(0) 推荐(0)
摘要://c//https://github.com/WEIZIBIN/acm/blob/master/hdu1004.c#include <stdio.h>#include <string.h>int main(){int i, n, j;char s[1005][15];int count[1005] 阅读全文
posted @ 2017-01-10 13:09 王坤1993 阅读(127) 评论(0) 推荐(0)
摘要://c //https://github.com/WEIZIBIN/acm/blob/master/hdu1005.c#include <stdio.h>int main(){int i, result, a, b, j;long n;int f[50] = {0};f[1] = 1;f[2] = 阅读全文
posted @ 2017-01-10 13:09 王坤1993 阅读(124) 评论(0) 推荐(0)
摘要://c++//https://github.com/zzdxfei/hduacm/blob/master/1003.cpp#include #include using namespace std; void ComputeMaxSubstr(const vector& sets,int& max_ 阅读全文
posted @ 2017-01-10 13:08 王坤1993 阅读(144) 评论(0) 推荐(0)
摘要://c#include"stdio.h"int main(){int i, j;while(scanf("%d%d", &i, &j) == 2)printf("%d\n", i + j);return 0;} //c++ #include using namespace std;int main( 阅读全文
posted @ 2017-01-10 13:07 王坤1993 阅读(184) 评论(0) 推荐(0)
摘要://c//https://github.com/ssdutyuyang199401/hduacm/blob/master/1002.c#include<stdio.h>#include<string.h>int shu(char a){return (a-'0');}int main(){char 阅读全文
posted @ 2017-01-10 13:07 王坤1993 阅读(211) 评论(0) 推荐(0)
摘要://c#include "stdio.h"int main() {int a = 0, sum = 0;while (scanf("%d", & a) != EOF) {if ((a << 31) >> 31 == 0) {sum = a / 2;sum *= a + 1;printf("%d\n\ 阅读全文
posted @ 2017-01-10 13:06 王坤1993 阅读(133) 评论(0) 推荐(0)