Merge pull request #3 from KiritoTRw/master

QUST OJ Added.
This commit is contained in:
Kirigaya Kazuto 2016-04-27 18:44:31 +08:00
commit 577ecf0735
2 changed files with 183 additions and 0 deletions

112
QUSTOJ/1640.cpp Normal file
View File

@ -0,0 +1,112 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
//We have to say this is a mash-up of terrible code. But at least, it solves the problem.
typedef struct
{
double x,y;
} point;
typedef struct
{
double k,b;
} line_s;
point inc[3];
line_s line[3];
int main()
{
int x,y;
int count=0;
while(scanf("%lf %lf %lf %lf %lf %lf",&inc[0].x,&inc[0].y,&inc[1].x,&inc[1].y,&inc[2].x,&inc[2].y)==6)
{
line[0].k=(inc[1].y-inc[0].y)/(inc[1].x-inc[0].x);
line[0].b=inc[0].y-line[0].k*inc[0].x;
line[1].k=(inc[2].y-inc[1].y)/(inc[2].x-inc[1].x);
line[1].b=inc[1].y-line[1].k*inc[1].x;
line[2].k=(inc[0].y-inc[2].y)/(inc[0].x-inc[2].x);
line[2].b=inc[2].y-line[2].k*inc[2].x;
if(!(inc[0].x!=inc[1].x&&inc[1].x!=inc[2].x&&inc[0].x!=inc[2].x))
{
if(inc[0].x==inc[1].x)
{
count=0;
for(x=1; x<100; x++)
{
for(y=1; y<100; y++)
{
if((x-inc[0].x)*(inc[2].x-inc[0].x)>=0)
{
if((y-line[1].k*x-line[1].b)*(inc[0].y-line[1].k*inc[0].x-line[1].b)>=0)
{
if((y-line[2].k*x-line[2].b)*(inc[1].y-line[2].k*inc[1].x-line[2].b)>=0)
{
count++;
}
}
}
}
}
}
else if(inc[1].x==inc[2].x)
{
count=0;
for(x=1; x<100; x++)
{
for(y=1; y<100; y++)
{
if((x-inc[1].x)*(inc[0].x-inc[1].x)>=0)
{
if((y-line[0].k*x-line[0].b)*(inc[2].y-line[0].k*inc[2].x-line[0].b)>=0)
{
if((y-line[2].k*x-line[2].b)*(inc[1].y-line[2].k*inc[1].x-line[2].b)>=0)
{
count++;
}
}
}
}
}
}
else if(inc[2].x==inc[0].x)
{
count=0;
for(x=1; x<100; x++)
{
for(y=1; y<100; y++)
{
if((x-inc[2].x)*(inc[1].x-inc[2].x)>=0)
{
if((y-line[0].k*x-line[0].b)*(inc[2].y-line[0].k*inc[2].x-line[0].b)>=0)
{
if((y-line[1].k*x-line[1].b)*(inc[0].y-line[1].k*inc[0].x-line[1].b)>=0)
{
count++;
}
}
}
}
}
}
printf("%d\n",count);
continue;
}
count=0;
for(x=1; x<100; x++)
{
for(y=1; y<100; y++)
{
if((y-line[0].k*x-line[0].b)*(inc[2].y-line[0].k*inc[2].x-line[0].b)>=0)
{
if((y-line[1].k*x-line[1].b)*(inc[0].y-line[1].k*inc[0].x-line[1].b)>=0)
{
if((y-line[2].k*x-line[2].b)*(inc[1].y-line[2].k*inc[1].x-line[2].b)>=0)
{
count++;
}
}
}
}
}
printf("%d\n",count);
}
}

71
QUSTOJ/1648.cpp Normal file
View File

@ -0,0 +1,71 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
class bign
{
public:
//WARNING: We use public here to reduce time consumed on Interface, although this is not a recommended way.
int data[3000];
void set_empty()
{
memset(data,0,sizeof(int)*3000);
}
int lenx()
{
for(int i=3000-1;i>=0;i--)
{
if(data[i]!=0) return i+1;
}
return 0;
}
};
bign sum,tmp,a;
char buff[1024];
void ConvertSTRtoBIGN(const char* incstr,bign& incbign)
{
int len=strlen(incstr);
for(int i=0;i<len;i++)
{
incbign.data[len-i-1]=incstr[i]-'0';
}
}
int main()
{
int times,n;
scanf("%d%*c",&times);
for(;times>0;times--)
{
scanf("%d%*c",&n);
sum.set_empty();
for(;n>0;n--)
{
gets(buff);
tmp.set_empty();
ConvertSTRtoBIGN(buff,tmp);
int lena=tmp.lenx();
int lenb=sum.lenx();
int maxlen=(lena>lenb)?(lena):(lenb);
for(int i=0;i<maxlen;i++)
{
sum.data[i]+=tmp.data[i];
if(sum.data[i]>9)
{
sum.data[i]-=10;
sum.data[i+1]++;
}
}
}
int slen=sum.lenx();
for(int i=slen-1;i>=0;i--)
{
printf("%d",sum.data[i]);
}
printf("\n");
}
return 0;
}