diff --git a/QUSTOJ/1640.cpp b/QUSTOJ/1640.cpp new file mode 100644 index 0000000..47c3865 --- /dev/null +++ b/QUSTOJ/1640.cpp @@ -0,0 +1,112 @@ +#include +#include +#include +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); + } +} diff --git a/QUSTOJ/1648.cpp b/QUSTOJ/1648.cpp new file mode 100644 index 0000000..8a258c9 --- /dev/null +++ b/QUSTOJ/1648.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +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;i0;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;i9) + { + 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; +}