From f270b9dcfd2e91c76c41a562c86b873fd4ff84da Mon Sep 17 00:00:00 2001 From: KiritoTRw <3021577574@qq.com> Date: Fri, 12 Aug 2016 10:52:18 +0800 Subject: [PATCH] Powered By HC TECH : AutoACer Engine --- HDOJ/1081_autoAC.cpp | 49 +++++++++++++++++++++++++++++++ HDOJ/1082_autoAC.cpp | 63 ++++++++++++++++++++++++++++++++++++++++ HDOJ/1083_autoAC.cpp | 61 +++++++++++++++++++++++++++++++++++++++ HDOJ/1084_autoAC.cpp | 46 ++++++++++++++++++++++++++++++ HDOJ/1085_autoAC.cpp | 24 ++++++++++++++++ HDOJ/1086_autoAC.cpp | 40 ++++++++++++++++++++++++++ HDOJ/1087_autoAC.cpp | 40 ++++++++++++++++++++++++++ HDOJ/1088_autoAC.cpp | 37 ++++++++++++++++++++++++ HDOJ/1089_autoAC.cpp | 10 +++++++ HDOJ/1090_autoAC.cpp | 11 +++++++ HDOJ/1091_autoAC.cpp | 12 ++++++++ HDOJ/1092_autoAC.cpp | 16 +++++++++++ HDOJ/1093_autoAC.cpp | 20 +++++++++++++ HDOJ/1094_autoAC.cpp | 16 +++++++++++ HDOJ/1095_autoAC.cpp | 12 ++++++++ HDOJ/1096_autoAC.cpp | 20 +++++++++++++ HDOJ/1097_autoAC.cpp | 23 +++++++++++++++ HDOJ/1098_autoAC.cpp | 24 ++++++++++++++++ HDOJ/1099_autoAC.cpp | 60 ++++++++++++++++++++++++++++++++++++++ HDOJ/1100_autoAC.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++ 20 files changed, 652 insertions(+) create mode 100644 HDOJ/1081_autoAC.cpp create mode 100644 HDOJ/1082_autoAC.cpp create mode 100644 HDOJ/1083_autoAC.cpp create mode 100644 HDOJ/1084_autoAC.cpp create mode 100644 HDOJ/1085_autoAC.cpp create mode 100644 HDOJ/1086_autoAC.cpp create mode 100644 HDOJ/1087_autoAC.cpp create mode 100644 HDOJ/1088_autoAC.cpp create mode 100644 HDOJ/1089_autoAC.cpp create mode 100644 HDOJ/1090_autoAC.cpp create mode 100644 HDOJ/1091_autoAC.cpp create mode 100644 HDOJ/1092_autoAC.cpp create mode 100644 HDOJ/1093_autoAC.cpp create mode 100644 HDOJ/1094_autoAC.cpp create mode 100644 HDOJ/1095_autoAC.cpp create mode 100644 HDOJ/1096_autoAC.cpp create mode 100644 HDOJ/1097_autoAC.cpp create mode 100644 HDOJ/1098_autoAC.cpp create mode 100644 HDOJ/1099_autoAC.cpp create mode 100644 HDOJ/1100_autoAC.cpp diff --git a/HDOJ/1081_autoAC.cpp b/HDOJ/1081_autoAC.cpp new file mode 100644 index 0000000..ef8ec5f --- /dev/null +++ b/HDOJ/1081_autoAC.cpp @@ -0,0 +1,49 @@ +#include +using namespace std; +int MaxSum1D(int *a, int n) +{ + int sum = -128, b = 0; + int i; + for (i=0; i 0) b += a[i]; + else b = a[i]; + if(b > sum) sum = b; + } + return sum; +} +int MaxSum2D(int a[][101], int m, int n) +{ + int sum = -128; + int i, j, k; + int *b = new int[n+1]; + for (i=0; i sum) + sum = Max; + } + } + return sum; +} +int main() +{ + int n, i, j; + int a[101][101]; + while (cin >> n) + { + for (i=0; i> a[i][j]; + } + } + cout << MaxSum2D(a, n, n) << endl; + } + return 0; +} diff --git a/HDOJ/1082_autoAC.cpp b/HDOJ/1082_autoAC.cpp new file mode 100644 index 0000000..a219dfd --- /dev/null +++ b/HDOJ/1082_autoAC.cpp @@ -0,0 +1,63 @@ +#include +#include +using namespace std; +const int MATRIX_LEN = 30; +const int INPUT_LEN = 200; +class Matrix +{ +public: + char name[2]; + int row, col; +}; +Matrix matrices[MATRIX_LEN]; +stack stackMatrices; +int main () +{ + int matricesNum; + scanf("%d",&matricesNum); + Matrix aMatrix; + for (int i = 0;i < matricesNum;i ++) + { + scanf("%s%d%d",aMatrix.name,&aMatrix.row,&aMatrix.col); + int pos = aMatrix.name[0] - 'A'; + matrices[pos] = aMatrix; + } + char input[INPUT_LEN]; + while (scanf("%s",input) != -1) + { + while ( ! stackMatrices.empty()) + stackMatrices.pop(); + int totalMultiCount = 0; + int isError = 0; + Matrix left, right; + for (int i = 0;i < strlen(input);i ++) + { + if (isalpha(input[i])) + { + aMatrix = matrices[ input[i] - 'A' ]; + stackMatrices.push(aMatrix); + continue; + } + if (input[i] == '(') + continue; + right = stackMatrices.top(); + stackMatrices.pop(); + left = stackMatrices.top(); + stackMatrices.pop(); + if (left.col != right.row) + { + isError = 1; + break; + } + totalMultiCount += left.row * left.col * right.col; + aMatrix.row = left.row; + aMatrix.col = right.col; + stackMatrices.push(aMatrix); + } + if (isError) + printf("error\n"); + else + printf("%d\n",totalMultiCount); + } + return 0; +} diff --git a/HDOJ/1083_autoAC.cpp b/HDOJ/1083_autoAC.cpp new file mode 100644 index 0000000..a1039fd --- /dev/null +++ b/HDOJ/1083_autoAC.cpp @@ -0,0 +1,61 @@ +#include +#include +using namespace std; +const int STUDENT_NUM = 305; +const int COURSE_NUM = 105; +int augmentedPathsNum; +int mapping[COURSE_NUM]; +int isVisited[COURSE_NUM]; +vector coursesAttend[STUDENT_NUM]; +int DFS_isAugmentedPathExist(int studentId) +{ + for (int i = 0;i < coursesAttend[studentId].size();i ++) + { + int courseId = coursesAttend[studentId][i]; + if (isVisited[courseId] != 0) + continue; + isVisited[courseId] = 1; + if (mapping[courseId] == -1 || DFS_isAugmentedPathExist(mapping[courseId])) + { + mapping[courseId] = studentId; + return 1; + } + } + return 0; +} +int main () +{ + int casesNum; + scanf("%d",&casesNum); + for (int i = 1;i <= casesNum;i ++) + { + int coursesNum, studentsNum; + scanf("%d%d", &coursesNum, &studentsNum); + for (int j = 1;j <= studentsNum;j ++) + coursesAttend[j].clear(); + for (int j = 1;j <= coursesNum;j ++) + { + int studentsNumOfCourse; + scanf("%d",&studentsNumOfCourse); + for (int k = 1;k <= studentsNumOfCourse;k ++) + { + int studentId; + scanf("%d",&studentId); + coursesAttend[studentId].push_back(j); + } + } + memset(mapping, -1, sizeof(mapping)); + augmentedPathsNum = 0; + for (int j = 1;j <= studentsNum;j ++) + { + memset(isVisited, 0, sizeof(isVisited)); + if ( DFS_isAugmentedPathExist(j) == 1 ) + augmentedPathsNum ++; + } + if (augmentedPathsNum == coursesNum) + printf("YES\n"); + else + printf("NO\n"); + } + return 0; +} diff --git a/HDOJ/1084_autoAC.cpp b/HDOJ/1084_autoAC.cpp new file mode 100644 index 0000000..f7ab12b --- /dev/null +++ b/HDOJ/1084_autoAC.cpp @@ -0,0 +1,46 @@ +#include +#include +using std::sort; +struct Node{ + int pos, num, s, val; +} stu[102]; +int arr[6]; +bool cmp1(Node a, Node b) +{ + if(a.num == b.num) return a.s < b.s; + return a.num > b.num; +} +bool cmp2(Node a, Node b) +{ + return a.pos < b.pos; +} +int main() +{ + int n, h, m, s, num; + while(scanf("%d", &n) == 1 && n > 0){ + for(int i = 1; i < 6; ++i) arr[i] = 0; + for(int i = 0; i < n; ++i){ + scanf("%d %d:%d:%d", &num, &h, &m, &s); + s += m * 60 + h * 3600; + stu[i].pos = i; + stu[i].num = num; + stu[i].s = s; + stu[i].val = 100 - (5 - num) * 10; + ++arr[num]; + } + sort(stu, stu + n, cmp1); + for(int i = 4, pos = 0; i; --i){ + if(arr[i]){ + while(stu[pos].num != i) ++pos; + if(arr[i] == 1) stu[pos++].val += 5; + for(int j = 0; j < arr[i] / 2; ++j) + stu[pos++].val += 5; + } + } + sort(stu, stu + n, cmp2); + for(int i = 0; i < n; ++i) + printf("%d\n", stu[i].val); + printf("\n"); + } + return 0; +} diff --git a/HDOJ/1085_autoAC.cpp b/HDOJ/1085_autoAC.cpp new file mode 100644 index 0000000..8eebdae --- /dev/null +++ b/HDOJ/1085_autoAC.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; +bool money[8002]; +int main() +{ + unsigned numFive,numTwo,numOne; + while(cin>>numOne>>numTwo>>numFive) + { + if(numOne==0&&numTwo==0&&numFive==0) + break; + memset(money,0,sizeof(bool)*(8002)); + for(unsigned i=0;i<=numFive;i++) + for(unsigned j=0;j<=numTwo;j++) + for(unsigned k=0;k<=numOne;k++) + money[k+j*2+i*5]=true; + for(int i=1;i<=8001;i++) + if(money[i]==false) + { + cout< +#include +using namespace std; +const int Max = 110; +struct Point +{ + double x, y; +}; +struct Segment +{ + Point s, e; +}; +Segment s[Max]; +double product(Point &a, Point &b, Point &c) +{ + double x1, y1, x2, y2; + x1 = a.x - c.x, y1 = a.y - c.y; + x2 = b.x - c.x, y2 = b.y - c.y; + return x1 * y2 - y1 * x2; +} +bool intersect(Segment &a, Segment &b) +{ + return product(a.s, a.e, b.s) * product(a.s, a.e, b.e) <= 0 && + product(b.s, b.e, a.s) * product(b.s, b.e, a.e) <= 0; +} +int main() +{ + int n, cnt; + while(scanf("%d", &n) && n) + { + for(int i=0; i +using namespace std; +int main() +{ + int i,j,k,l,n,m,t; + int a[1002],b[1002] = {0}; + while (scanf("%d",&n)!=EOF && n) + { + for (i=0;i a[j]) + { + if (b[j] > maxb) + { + maxb = b[j]; + } + } + } + b[i] += maxb; + if (b[i] > maxnum) + { + maxnum = b[i]; + } + } + printf("%d\n",maxnum); + } + return 0; +} diff --git a/HDOJ/1088_autoAC.cpp b/HDOJ/1088_autoAC.cpp new file mode 100644 index 0000000..d836c16 --- /dev/null +++ b/HDOJ/1088_autoAC.cpp @@ -0,0 +1,37 @@ +#include +#include +char a[81]; +int main() +{ + int p=0; + while(scanf("%s",a+1)!=EOF) + { + int len=strlen(a+1); + if(a[1]=='<') + { + if(a[2]=='b')printf("\n"); + else{ + if(p)printf("\n"); + for(int i=1;i<=80;i++)printf("-"); + printf("\n"); + } + p=0; + }else if(p==0) + { + for(int i=1;i<=len;i++)printf("%c",a[i]); + p=len; + }else if(p+len>=80) + { + printf("\n"); + for(int i=1;i<=len;i++)printf("%c",a[i]); + p=len; + }else + if(p+len<80){ + printf(" "); + for(int i=1;i<=len;i++)printf("%c",a[i]); + p+=len+1; + } + } + printf("\n"); + return 0; +} diff --git a/HDOJ/1089_autoAC.cpp b/HDOJ/1089_autoAC.cpp new file mode 100644 index 0000000..8699e69 --- /dev/null +++ b/HDOJ/1089_autoAC.cpp @@ -0,0 +1,10 @@ +#include +int main() +{ + int a,b; + while(scanf("%d%d",&a,&b)!=EOF) + { + printf("%d\n",a+b); + } + return 0; +} diff --git a/HDOJ/1090_autoAC.cpp b/HDOJ/1090_autoAC.cpp new file mode 100644 index 0000000..31e002e --- /dev/null +++ b/HDOJ/1090_autoAC.cpp @@ -0,0 +1,11 @@ +#include +int main(void) +{ + int a, b, n; + scanf("%d", &n); + while(n--&&scanf("%d%d", &a, &b)) + { + printf("%d\n", a + b); + } + return 0; +} diff --git a/HDOJ/1091_autoAC.cpp b/HDOJ/1091_autoAC.cpp new file mode 100644 index 0000000..7459ffe --- /dev/null +++ b/HDOJ/1091_autoAC.cpp @@ -0,0 +1,12 @@ +#include +int main(void) +{ + int a, b; + scanf("%d%d", &a, &b); + while(a != 0 || b != 0) + { + printf("%d\n", a + b); + scanf("%d%d", &a, &b); + } + return 0; +} diff --git a/HDOJ/1092_autoAC.cpp b/HDOJ/1092_autoAC.cpp new file mode 100644 index 0000000..39cbfd6 --- /dev/null +++ b/HDOJ/1092_autoAC.cpp @@ -0,0 +1,16 @@ +#include +int main(void) +{ + int a, n, i, sum; + while(scanf("%d", &n) && n != 0) + { + sum = 0; + for(i = 0; i < n; i ++) + { + scanf("%d", &a); + sum = sum + a; + } + printf("%d\n", sum); + } + return 0; +} diff --git a/HDOJ/1093_autoAC.cpp b/HDOJ/1093_autoAC.cpp new file mode 100644 index 0000000..aa59d9c --- /dev/null +++ b/HDOJ/1093_autoAC.cpp @@ -0,0 +1,20 @@ +#include +int main() +{ + int n, m, a, sum, i, j; + while(scanf("%d", &n) != EOF) + { + for(i = 0; i < n; i ++) + { + scanf("%d", &m); + sum = 0; + for(j = 0; j < m; j ++) + { + scanf("%d", &a); + sum = sum + a; + } + printf("%d\n", sum); + } + } + return 0; +} diff --git a/HDOJ/1094_autoAC.cpp b/HDOJ/1094_autoAC.cpp new file mode 100644 index 0000000..47558e9 --- /dev/null +++ b/HDOJ/1094_autoAC.cpp @@ -0,0 +1,16 @@ +#include +int main(void) +{ + int n, a, sum, i; + while(scanf("%d", &n) != EOF) + { + sum = 0; + for(i = 0; i < n; i ++) + { + scanf("%d", &a); + sum = sum + a; + } + printf("%d\n", sum); + } + return 0; +} diff --git a/HDOJ/1095_autoAC.cpp b/HDOJ/1095_autoAC.cpp new file mode 100644 index 0000000..68ae8c3 --- /dev/null +++ b/HDOJ/1095_autoAC.cpp @@ -0,0 +1,12 @@ +#include +int main(void) +{ + int a, b, i = 0; + while(i < 5) + { + scanf("%d%d", &a, &b); + printf("%d\n\n", a + b); + i ++; + } + return 0; +} diff --git a/HDOJ/1096_autoAC.cpp b/HDOJ/1096_autoAC.cpp new file mode 100644 index 0000000..28c5a25 --- /dev/null +++ b/HDOJ/1096_autoAC.cpp @@ -0,0 +1,20 @@ +#include +int main(void) +{ + int n, m, a, sum, i, j; + scanf("%d", &n); + for(i = 0; i < n; i ++) + { + scanf("%d", &m); + sum = 0; + for(j = 0; j < m; j ++) + { + scanf("%d", &a); + sum = sum + a; + } + printf("%d\n", sum); + if(i != n - 1) + printf("\n"); + } + return 0; +} diff --git a/HDOJ/1097_autoAC.cpp b/HDOJ/1097_autoAC.cpp new file mode 100644 index 0000000..0c7221e --- /dev/null +++ b/HDOJ/1097_autoAC.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int a,b; + while(scanf("%d%d",&a,&b)!=EOF) + { + a%=10; + if(a==0||a==5||a==6||a==1) printf("%d\n",a); + else if(a==4||a==9) + { + printf("%d\n",b%2==0?a*a%10:a); + } + else + { + if(b%4==1) printf("%d\n",a); + else if(b%4==2) printf("%d\n",a*a%10); + else if(b%4==3) printf("%d\n",a*a*a%10); + else printf("%d\n",a*a*a*a%10); + } + } + return 0; +} diff --git a/HDOJ/1098_autoAC.cpp b/HDOJ/1098_autoAC.cpp new file mode 100644 index 0000000..eae844e --- /dev/null +++ b/HDOJ/1098_autoAC.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; +int main() +{ + int k,a; + while(cin>>k) + { + if(k%65==0) + { + cout<<"no"< +#include +typedef __int64 ll; +ll gcd(ll a,ll b) +{ + if(b==0) + return a; + else + return gcd(b,a%b); +} +ll lcm(ll a,ll b) +{ + return a/gcd(a,b)*b; +} +ll numlen(ll n) +{ + ll l=0; + while(n) + { + n=n/10; + l++; + } + return l; +} +int main() +{ + ll n,son,mother,g,d,i; + while(scanf("%I64d",&n)!=EOF) + { + mother=1,son=0; + for(i=1;i<=n;i++) + mother=lcm(mother,i); + for(i=1;i<=n;i++) + son=son+mother/i; + son=son*n; + g=gcd(mother,son); + son=son/g; + mother=mother/g; + d=son/mother; + son=son%mother; + if(son==0) + { + printf("%d\n",d); + continue; + } + ll l1=numlen(d); + ll l2=numlen(mother); + for(i=0;i<=l1;i++) + printf(" "); + printf("%I64d\n",son); + printf("%I64d ",d); + for(i=1;i<=l2;i++) + printf("-"); + printf("\n"); + for(i=0;i<=l1;i++) + printf(" "); + printf("%I64d\n",mother); + } + return 0; +} diff --git a/HDOJ/1100_autoAC.cpp b/HDOJ/1100_autoAC.cpp new file mode 100644 index 0000000..2592430 --- /dev/null +++ b/HDOJ/1100_autoAC.cpp @@ -0,0 +1,68 @@ +#include +__int64 array[21]; +int init() +{ + array[0]=1; + array[1]=1; + for(int i=2;i<=20;i++) + { + array[i]=0; + for(int j=0;jarray[i]*array[num-1-i]) + { + n-=array[i]*array[num-1-i]; + } + else + { + __int64 x=n%array[num-1-i]==0?n/array[num-1-i]:n/array[num-1-i]+1; + if(i!=0) + { + printf("("); + dfs(i,x); + printf(")"); + } + printf("X"); + if(num-1-i!=0) + { + printf("("); + dfs(num-1-i,n-array[num-1-i]*(x-1)); + printf(")"); + } + return 0; + } + } + return 0; +} +int main() +{ + __int64 n; + init(); + while(scanf("%I64d",&n)!=EOF&&n>0) + { + __int64 temp=0; + int num; + for(int i=1;i<=20;i++) + { + if(temp+array[i]>=n) + { + n-=temp; + num=i; + break; + } + temp+=array[i]; + } + dfs(num,n); + printf("\n"); + } + return 0; +}