自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 1007 Maximum Subsequence Sum (25分)

注意:输出的是最大子序列头尾指针所指向的值而不是指针本身#include<stdio.h>#define MAX 10001int max(int a,int b){ return a>b?a:b;}int main(){ int n; while(~scanf("%d",&n)){ int qs[n]; for(int i=0;i<n;i++){ scanf("%d",&qs[i]); } int dp[n]; int

2021-01-28 16:18:03 66

原创 PAT - 1017 A除以B

注意点1.当结果数组的第1位为0时,注意输出格式;2.当被除数小于除数时,结果数组为0,注意输出格式#include<stdio.h>#include<string.h>int main(){ char num[1001]; int d; int ans[1001]; while(~scanf("%s%d",&num,&d)){ int j = 0; int temp = 0; while(num[j]!='\0'){ temp

2021-01-13 00:22:55 61

原创 1375C - Element Extermination

#include<iostream>using namespace std;int main(){ int t; cin>>t; while(t--){ int n; cin>>n; int arr[n+1]; for(int i=0;i<n;i++){ cin>>arr[i]; } if(arr[0]>arr[n-1]){ cout<<"NO"<<endl; }else{

2020-07-10 22:02:51 124

原创 1375B - Neighbor Grid

#include<iostream>using namespace std;int main(){ int t; cin>>t; while(t--){ int n,m; cin>>n>>m; int arr[n+1][m+1]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>arr[i][j]; } } int cmp[n+1]

2020-07-10 20:45:54 161

原创 1375A - Sign Flipping

#include<iostream>using namespace std;int main(){ int t; cin>>t; while(t--){ int n; cin>>n; int arr[n+1]; for(int i=0;i<n;i++){ cin>>arr[i]; if(i%2==0&&arr[i]>0) arr[i] = -arr[i]; else if(i%2==1&

2020-07-10 19:37:46 124

原创 C. Move Brackets

#include<iostream>#include<cstring>using namespace std;int main(){ int t; cin>>t; for(int i=0;i<t;i++){ int n; cin>>n; char str[n+1]; cin>>str; char stack[n+1]; int j = 0,k = -1; while(str[j]!='\0'){

2020-07-04 21:35:08 1259

原创 1374B - Multiply by 2, divide by 6

#include<iostream>#include<cmath>using namespace std;int main(){ int num; cin>>num; for(int i=0;i<num;i++){ long int x; cin>>x; int count = 0; while(x!=1){ if(x%6==0){ x = x/6; }else{ if(x%3!=0){

2020-07-04 20:38:17 2062

原创 1374A - Required Remainder

#include<iostream>using namespace std;int main(){ int num; cin>>num; for(int i=0;i<num;i++){ long int x,y,n; cin>>x>>y>>n; long int count = n/x; if((count*x+y)<=n){ cout<<count*x+y<<endl; }

2020-07-04 19:53:05 1686

原创 1369B-AccurateLee

#include<iostream>#include<cstring>using namespace std;int main(){ int n; cin>>n; for(int k=0;k<n;k++){ int len; cin>>len; char str[100000]; cin>>str; int i = 0,j = len-1; while(str[i]!='1') i++; while(

2020-06-25 16:41:16 147

原创 1370A-Maximum GCD

#include<iostream>using namespace std;int main(){ int n; cin>>n; for(int i=0;i<n;i++){ int num; cin>>num; cout<<num/2<<endl; }}

2020-06-22 19:22:02 172

原创 116A - Tram

#include<iostream>using namespace std;int main(){ int n; cin>>n; int max = 0; int real = 0; for(int i=0;i<n;i++){ int s1,s2; cin>>s1>>s2; int k = real-s1+s2; real = real-s1+s2; if(max<k){ max = k; } }

2020-06-22 00:05:17 90

原创 546A - Soldier and Bananas

#include<iostream>using namespace std;int main(){ int first,avil,need; cin>>first>>avil>>need; int ans = first*((need+1)*need/2)-avil; if(ans>0){ cout<<ans<<endl; }else{ cout<<0<<endl; }}

2020-06-21 23:45:58 78

原创 236A - Boy or Girl

#include<iostream>#include<cstring>using namespace std;int main(){ char str[101]; cin>>str; int count[26]; memset(count,0,sizeof(count)); int i = 0; int ans = 0; while(str[i]!='\0'){ int num = str[i] - 'a'; count[num]++;

2020-06-21 23:45:17 167

原创 266A-Stones on the Table

#include<iostream>#include<cstring>using namespace std;int main(){ char str[55]; int i = 1; int n; cin>>n; cin>>str; int ans = 0; while(str[i]!='\0'){ if(str[i]==str[i-1]){ ans++; } i++; } cout<<ans<&l

2020-06-21 23:09:32 103

原创 281A-Word Capitalization

#include<iostream>#include<cstring>using namespace std;int main(){ char str[1001]; cin>>str; if(str[0]>='a'&&str[0]<='z'){ str[0] = str[0] - 32; } cout<<str<<endl;}

2020-06-21 23:08:58 102

原创 263A - Beautiful Matrix

#include<iostream>using namespace std;int abs(int a){ if(a<0){ return -a; }else{ return a; }}int main(){ int map[5][5]; int row = 0,column = 0; for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ cin>>map[i][j]; if(map[

2020-06-21 20:37:24 131

原创 A. Petya and Strings

#include<iostream>#include<cstring>using namespace std;void invert(char str[]){// convert upper to lower int i = 0; while(str[i]!='\0'){ if(str[i]<='Z'&&str[i]>='A'){ str[i] = str[i] + 32; } i++; }}int compare(c

2020-06-21 20:19:51 227

原创 282A. Bit++

#include<iostream>#include<cstring>using namespace std;int main(){ int n; cin>>n; int x = 0; char str[4]; for(int i=0;i<n;i++){ cin>>str; if(str[1]=='+'){ x++; }else{ x--; } } cout<<x<<endl;}

2020-06-21 19:59:35 138

原创 50A Domino piling

#include<iostream>using namespace std;int main(){ int m,n; cin>>m>>n; int ans = 0; ans = (m/2)*n; if(m%2!=0){ ans+=(n/2); cout<<ans<<endl; }else{ cout<<ans<<endl; }}

2020-06-21 19:52:55 100

原创 数据结构~~~~~~~Prim算法

通过Prim算法求最小生成树(邻接矩阵存储)://return the lowcost of MinSpanTree;#include<stdio.h>#include<string.h>#define MaxSize 30#define InFinity 99999typedef struct MGraph{ int edge[MaxSize][MaxSiz...

2020-04-11 19:08:11 100

原创 1071: 数塔(动态规划)

题目描述:PIPI在CSU的某个角落发现了一座金字塔,而且这座金字塔是由数字组成的(如下图所示),现在PIPI想到塔顶去看看,它可以从底层任意一个数字出发逐层爬上去。PIPI每次可以爬至上一层相邻的数字上。现在PIPI想知道,它如何选择爬上去的路径,使该路径经过的数字和最大?输入:多组数据每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔的高度,接下来用...

2020-04-09 19:41:04 299

原创 1008 最大连续子序列(C,动态规划)

题目描述:给定 K 个整数的序列{ N1, N2, …, NK } ,其任意连续子序列可表示为{ Ni, Ni+1,…,Nj} ,其中1 <= i<= j <= K。最大连续子序列是所有连续子序列中元素和最大的一个,例如给定序列{ -2, 11, -4, 13, -5, -2 } ,其最大连续子序列为{ 11, -4, 13 } ,最大和为20。编写程序得到其中最大子序列的...

2020-04-04 18:28:29 234

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除