编程
头发太多而被寺庙拒收
总要让自己强大起来,才能保护身边的人
展开
-
腾讯50题刷题六&leetcode169
文章目录题目解法一思路代码解法二思路代码题目Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and th...原创 2019-08-12 20:37:32 · 152 阅读 · 0 评论 -
CCF201603-01
#include<iostream>using namespace std;int a[1001];int main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; } int count=0; for(int i=1;i<n-...原创 2018-08-21 20:18:30 · 123 阅读 · 0 评论 -
CCF201512-01
#include<iostream>#include<cstring>using namespace std;int main(){ char a[11]; cin>>a; int sum=0; int len=strlen(a); for(int i=0;i<len;i++){ sum+=a[...原创 2018-08-21 20:17:49 · 158 阅读 · 0 评论 -
CCF201509-01
#include<iostream>using namespace std;int main(){ int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } int count=1; for(int i=0;i<n...原创 2018-08-21 20:17:11 · 93 阅读 · 0 评论 -
CCF201503-01
#include<iostream>using namespace std;int a[1001][1001];int main(){ int m,n; cin>>m>>n; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cin>&g...原创 2018-08-21 20:14:38 · 145 阅读 · 0 评论 -
201412-01
#include<iostream>using namespace std;int main(){ int n; cin>>n; int a[n],c[n]; int b[1001]; for(int i=0;i<1002;i++) { b[i]=0; } for(int i=0;i&...原创 2018-08-21 20:14:00 · 93 阅读 · 0 评论 -
CCF201409-01
#include<iostream>#include<algorithm>using namespace std;int main(){ int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i } int temp=0;...原创 2018-08-21 20:13:28 · 131 阅读 · 0 评论 -
CCF201403-01
#include<iostream>#include<algorithm>using namespace std;int main(){ int n; cin>>n; int a[n]; int b[1001]; for(int i=0;i<1001;i++) { b[i]=0; ...原创 2018-08-21 20:12:56 · 87 阅读 · 0 评论 -
CCF201312-01
#include<iostream>using namespace std;int main(){ int n,t; cin>>n; int b[n]; int a[10001]; for(int i=0;i<10001;i++){ a[i]=0; } for(int i=0;i<n;i...原创 2018-08-21 20:12:20 · 196 阅读 · 0 评论 -
CCF201509-02
#include<iostream>using namespace std;int main(){ int month[]={31,28,31,30,31,30,31,31,30,31,30,31}; int y,d; cin>>y>>d; if(y%400==0||(y%4==0&&y%100!=0)) ...原创 2018-08-21 22:36:43 · 135 阅读 · 0 评论 -
软微java作业第三次-计蒜客删除数组重复元素
package com.school; import java.util.Scanner; public class Main3 {//排序后的数组删除重复数字public static void main(String[] args) {Scanner input = new Scanner(System.in);int n;int length = 1;...原创 2019-02-03 13:10:09 · 126 阅读 · 0 评论 -
腾讯50题刷题九&leetcode124
文章目录题目解法思路代码题目Given a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-...原创 2019-08-21 11:20:24 · 284 阅读 · 0 评论 -
腾讯50题刷题八&leetcode104
文章目录题目解法一思路一代码解法二思路代码题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is...原创 2019-08-14 10:25:54 · 192 阅读 · 0 评论 -
腾讯50题刷题七&leetcode231
文章目录题目解法一思路代码解法二思路题目Given an integer, write a function to determine if it is a power of two.Example 1:Input: 1Output: trueExample 2:Input: 16Output: trueExample 3:Input: 218Output: false解法...原创 2019-08-14 10:13:17 · 142 阅读 · 0 评论 -
腾讯50题刷题四&leetcode148
文章目录题目解法一思路代码解法二思路代码题目Sort a linked list in O(n log n) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4-...原创 2019-08-09 16:06:05 · 151 阅读 · 0 评论 -
腾讯50题刷题三&leetcode122
文章目录题目思路代码题目Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like...原创 2019-08-08 17:17:29 · 239 阅读 · 0 评论 -
腾讯50题刷题二&leetcode215
文章目录题目解法一思路代码解法二思路:代码:解法三:思路:代码题目Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,...原创 2019-08-05 10:57:55 · 258 阅读 · 0 评论 -
腾讯50题刷题一&leetcode155
文章目录题目:解法一思路代码解法二思路代码题目:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of t...原创 2019-08-04 18:27:55 · 397 阅读 · 0 评论 -
软微java作业第四次-最大子序列和
package com.school; import java.util.Scanner; public class Main4 {//最大子列和public static void main(String[] args) {int n;int[] list = new int[1010];long max = 0, temp = 0, num = 0;Sc...原创 2019-02-03 14:46:05 · 167 阅读 · 0 评论 -
CCF201709-02
#include<iostream>#include<algorithm>using namespace std;struct Key{ int key; int time; int operation;}Op[2000];bool cmp(Key key1, Key key2)//{ if (key1.time != key2...原创 2018-08-24 08:36:59 · 268 阅读 · 0 评论 -
CCF201609-02
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm> using namespace std; int a[25][6]; int main(){ int n,i,j,k,cnt; scanf("%d",&n...原创 2018-08-23 15:36:21 · 126 阅读 · 0 评论 -
CCF201312-03
#include<iostream>#include<algorithm>using namespace std;int main(){ int n,num=0; cin>>n; int arr[n]; for(int i=0;i<n;i++){ cin>>arr[i]; } ...原创 2018-08-16 17:58:03 · 111 阅读 · 0 评论 -
CCF201712-02
#include<iostream>using namespace std;int main(){ int n,k,count=0; cin>>n>>k; int a[n]={0}; int sum=n; while(sum>1){//只剩一人,结束 for(int i=0;i<n;i++...原创 2018-08-02 18:59:16 · 172 阅读 · 0 评论 -
CCF201609-01
#include<iostream>#include<algorithm>using namespace std;int n,maxN = 0;int main(){ int a,b; cin>>n>>a; while(--n) { cin>>b; maxN = m...原创 2018-08-02 17:50:15 · 107 阅读 · 0 评论 -
CCF201703-01
#include <iostream>using namespace std;int a[1005];int main(){ int n,k; cin>>n>>k; for(int i=1;i<=n;i++) { cin>>a[i]; } int sum=0; i...原创 2018-08-02 17:17:03 · 254 阅读 · 0 评论 -
CCF201612-01
#include<iostream>#include<algorithm>using namespace std;int val[10000];int main(){int n;cin>>n;for(int i=0;i<n;i++) cin>>val[i];sort(val,val+n);int mid=val[n/...原创 2018-08-02 17:01:32 · 119 阅读 · 0 评论 -
201712-01
#include<iostream>#include<math.h>using namespace std;int main(){int a[100],n,i,j;int min=1000000;cin>>n;for(i=0;i<n;i++){cin>>a[i];}for(i=0;i<n-1;i++){for(j=i...原创 2018-06-15 18:08:33 · 116 阅读 · 0 评论 -
CCF-201709-1
#include<iostream>using namespace std;int main(){int n,a,b,c,d,e,count;cin>>n;a=n/50;b=n%50;c=b/30;d=b%30;e=d/10;count=7*a+4*c+e;cout<<count<<endl;}原创 2018-06-15 16:39:28 · 137 阅读 · 0 评论 -
CCF201803-2
#include<iostream>using namespace std;int main(){int n,L,t,i,j;cin>>n>>L>>t;int a[100],v[100];for(i=0;i<n;i++) {v[i]=1;cin>>a[i];}while(t--){for(i=0;i<n...原创 2018-06-14 21:12:13 · 463 阅读 · 0 评论 -
CCF201403-03
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<map>using namespace std;char s[300];map<char,int> o,a;map<char,string>原创 2018-08-16 17:58:53 · 226 阅读 · 0 评论 -
CCF201409-02
#include<iostream>#include<map>using namespace std;int main(){ int n; cin>>n; int i; int map[101][101]={0}; for(i=0;i<n;i++){ int a[4]; cin&...原创 2018-08-16 17:59:48 · 124 阅读 · 0 评论 -
CCF201403-02
#include <iostream>using namespace std;int main(){ int n; cin >> n; int i; int map[100][100] = { 0 }; for (i = 0; i < n; i++){ int a[4]; cin >&g...原创 2018-08-23 15:34:24 · 120 阅读 · 0 评论 -
CCF201703-02
#include<iostream>#include<cstdio>using namespace std;const int N = 1005;int a[N];int n; void forward(int p, int q){ for(int i = 0; i < n; i ++){ if(a[i]==p){ ...原创 2018-08-23 15:23:31 · 208 阅读 · 0 评论 -
CCF201612-02
#include<iostream>#include<cstdio>using namespace std;int main(){ int t,a,ans; cin>>t; for(int i=0;i<=1800;i++) //暴力枚举,这里税前工资要枚举更大些 { int a=i*100-3500...原创 2018-08-23 15:20:27 · 144 阅读 · 0 评论 -
CCF201603-02
#include<iostream>using namespace std;int main(){ int container[15][10]; int pattern[4][4]; int offset; //默认空余行为14 int col[4]={14,14,14,14}; //注意:默认15,原因:如果ma过小,当col=1,...原创 2018-08-23 15:19:57 · 138 阅读 · 0 评论 -
CCF201412-02
#include <iostream> using namespace std; const int N = 500;int a[N][N]; int main(){ int n, x, y; // 输入数据 cin >> n; for(int i=0; i<n; i++) for(int j=0; ...原创 2018-08-23 15:19:08 · 106 阅读 · 0 评论 -
201312-02
#include<iostream>#include<cstring>using namespace std;int main(){ int s[15]; char str[15]; for(int i=0,j=0;i<13;i++){ cin>>str[i]; if(str[i]!='-'){...原创 2018-08-23 15:18:25 · 115 阅读 · 0 评论 -
CCF201512-02
#include<iostream>using namespace std;int a[35][35],b[35][35];int main(){ int m,n; cin>>m>>n; for(int i=0;i<m;i++) for(int j=0;j<n;j++){ cin>>a...原创 2018-08-23 15:16:59 · 151 阅读 · 0 评论 -
CCF-201803-1
#include<iostream>using namespace std;int main(){int i,count=0,num=0;while(cin>>i){if(i==0)break;else{if(i==2){num++;count+=num*2;}if(i==1){num=0;count++;}}}cout<<...原创 2018-06-14 16:33:23 · 230 阅读 · 0 评论