Merge pull request #4 from Kiritow/master

Catch up with you~
This commit is contained in:
KiritoTRw 2016-04-28 09:08:45 +08:00
commit d6d83f3d8e
2 changed files with 116 additions and 0 deletions

74
QUSTOJ/1229.c Normal file
View File

@ -0,0 +1,74 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int map[110][110];
int maxofmap;
int findinmap(int l,int h,int max)
{
int i,j,p,q;
int state=-1;
int maxans;
int tmp;
for(i=0;i<max-l+1;i++)
{
for(j=0;j<max-h+1;j++)
{
tmp=0;
for(p=0;p<l;p++)
{
for(q=0;q<h;q++)
{
tmp+=map[1+p+i][1+q+j];
}
}
if(state<0)
{
state++;
maxans=tmp;
}
else if(tmp>maxans)
{
maxans=tmp;
}
}
}
return maxans;
}
void deal(int max)
{
int l,h,tmp;
for(l=1;l<=max;l++)
{
for(h=1;h<max;h++)
{
if((tmp=findinmap(l,h,max))>maxofmap)
{
maxofmap=tmp;
}
}
}
printf("%d\n",maxofmap);
}
int main()
{
int all,n,i,j;
scanf("%d",&all);
for(;all>0;all--)
{
scanf("%d",&n);
memset(map,0,sizeof(int)*110*110);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%d",&map[i][j]);
}
}
maxofmap=map[1][1];
deal(n);
}
return 0;
}

42
QUSTOJ/1231.cpp Normal file
View File

@ -0,0 +1,42 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char buff[128];
void deal()
{
int dec,binary;
scanf("%d %d",&dec,&binary);
int orgdec=dec;
memset(buff,0,128);
int i=0;
while(dec>=binary)
{
buff[i++]='0'+dec%binary;
dec=dec/binary;
}
buff[i]='0'+dec;
int len=strlen(buff);
int slen=len/2;
#ifndef __GNUC__
printf("%s\n",buff);
#endif
for(i=0;i<slen;i++)
{
if(buff[i]!=buff[len-i-1])
{
printf("Number %d is not palindrome in basis %d\n",orgdec,binary);
return;
}
}
printf("Number %d is palindrome in basis %d\n",orgdec,binary);
}
int main()
{
int all;
scanf("%d",&all);
for(;all>0;all--)
{
deal();
}
return 0;
}