Powered By HC TECH : AutoACer Engine

This commit is contained in:
KiritoTRw 2016-08-12 10:05:27 +08:00 committed by GitHub
parent 71b61ee74a
commit 5b1403fd7e
11 changed files with 463 additions and 0 deletions

10
HDOJ/1000_autoAC.cpp Normal file
View File

@ -0,0 +1,10 @@
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
cout<<a+b<<endl;
return 0;
}

14
HDOJ/1001_autoAC.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int main()
{
int n,sum;
while(cin>>n)
{
sum = 0;
for(int i = 1;i <= n;++i)
sum += i;
cout<<sum<<endl<<endl;
}
return 0;
}

61
HDOJ/1002_autoAC.cpp Normal file
View File

@ -0,0 +1,61 @@
#include <iostream>
#include <string.h>
using namespace std;
void add ( char a[], char b[] )
{
char sum[1010] = {' '};
int flg = 0;
int temp = 0;
int len_a = strlen ( a );
int len_b = strlen ( b );
int i = len_a;
int j = len_b;
for ( ; i > 0; i-- )
{
if ( j > 0 )
{
temp = a[i-1] + b[j-1] + flg - 96;
j--;
}
else temp = a[i-1] + flg - 48;
if ( temp >= 10 )
{
flg = 1;
}
else flg = 0;
temp = temp % 10;
sum[i] = temp + 48;
}
if ( flg == 1 ) sum[0] = 49;
i = 0;
while ( i <= len_ )
{
if ( sum[i] != ' ' ) cout << sum[i];
i++;
}
cout << endl;
}
int main()
{
int N;
while ( cin >> N )
{
for ( int i = 1; i <= N; i++ )
{
char a[1000];
char b[1000];
cin >> a;
cin >> b;
int len_a = strlen ( a );
int len_b = strlen ( b );
cout << "Case " << i << ":\n" << a << " + " << b << " = ";
if ( len_a >= len_ )
{
add ( a, b );
}
else add ( b, a );
if ( i != N ) cout << endl;
}
}
return 0;
}

36
HDOJ/1003_autoAC.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
int data[100000];
int main()
{
int i,j,k,l,sum,b,e,max=0,t;
scanf("%d",&i);
for (j=1;j<=i;j++)
{
max = -100000;
scanf("%d",&k);
for (sum=0, l=0, t=0 , e=0;l<k;l++)
{
scanf("%d",&data[l]);
if (sum>=0)
{
sum+=data[l];
}
else
{
sum = data[l];
t = l;
}
if (sum>max)
{
max = sum;
b = t;
e = l;
}
}
printf("Case %d:\n",j);
printf("%d %d %d\n",max,b+1,e+1);
if (j != i)
printf("\n");
}
return 1;
}

55
HDOJ/1004_autoAC.cpp Normal file
View File

@ -0,0 +1,55 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char ballons[1000][15];
int sum[1000];
int ballons_idx;
int n;
int InBallons(char* tmp)
{
int i;
for (i=0;i<ballons_idx;i++)
{
if (strcmp(tmp,ballons[i]) == 0)
{
sum[i]++;
return 1;
}
}
return 0;
}
int FindMax()
{
int i, max=-1, idx=0;
for (i=0;i<ballons_idx;i++)
{
if (sum[i]>max)
{
max = sum[i];
idx = i;
}
}
return idx;
}
int main()
{
int i;
char tmp[15];
scanf("%d",&n);
while(n)
{
ballons_idx = 0;
memset(sum,0,sizeof(int)*1000);
for (i=0;i<n;i++)
{
scanf("%s",tmp);
if (InBallons(tmp) == 0)
{
strcpy(ballons[ballons_idx++],tmp);
}
}
printf("%s\n",ballons[FindMax()]);
scanf("%d",&n);
}
return 0;
}

27
HDOJ/1005_autoAC.cpp Normal file
View File

@ -0,0 +1,27 @@
#include<stdio.h>
int main()
{
int f[200],a,b,n,i;
while(scanf("%d%d%d",&a,&b,&n),a||b||n)
{
if(n>2)
{
f[1]=f[2]=1;
for(i=3;i<200;i++)
{
f[i]=(a*f[i-1]+b*f[i-2])%7;
if(f[i-1]==1&&f[i]==1)
break;
}
i-=2;
n=n%i;
if(n==0)
printf("%d\n",f[i]);
else
printf("%d\n",f[n]);
}
else
printf("1\n");
}
return 0;
}

36
HDOJ/1006_autoAC.cpp Normal file
View File

@ -0,0 +1,36 @@
#include<iostream>
#include<iomanip>
using namespace std;
double max(double a,double b,double c){
if(b>a) a=b;
if(c>a) a=c;
return a;
}
double min(double a,double b,double c){
if(b<a) a=b;
if(c<a) a=c;
return a;
}
int main(){
const double vsm=5.9;
const double vsh=719.0/120;
const double vmh=11.0/120;
const double tsm=3600.0/59;
const double tsh=43200.0/719;
const double tmh=43200.0/11;
double d,t,start,end;
while(cin>>d,d!=-1){
t=0;
for(int i=0;i<11;i++){
for(int j=(int)((tmh*i+d/vmh-d/vsm)/tsm);j<=(int)((tmh*(i+1)-d/vmh-d/vsm)/tsm);j++){
for(int k=(int)((tsm*j+d/vsm-d/vsh)/tsh);k<=(int)((tsm*(j+1)-d/vsm-d/vsh)/tsh);k++){
start=max(tsh*k+d/vsh,tsm*j+d/vsm,tmh*i+d/vmh);
end=min(tsh*(k+1)-d/vsh,tsm*(j+1)-d/vsm,tmh*(i+1)-d/vmh);
if(start<end) t+=end-start;
}
}
}
cout<<fixed<<setprecision(3)<<t/432<<endl;
}
return 0;
}

66
HDOJ/1007_autoAC.cpp Normal file
View File

@ -0,0 +1,66 @@
#include <algorithm>
using namespace std;
#include <stdio.h>
#include <math.h>
struct Point
{
double x;
double y;
};
int num;
Point points[100001];
Point assist[100001];
inline bool cmpx(Point a ,Point b )
{
return a.x < b.x;
}
inline bool cmpy(Point a ,Point b )
{
return a.y < b.y;
}
inline double space(Point a, Point b)
{
return (a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y);
}
inline double minBinary(double a,double b)
{
return a<b?a:b;
}
double binarySlove(int l,int r,Point* p)
{
if(r-l==1)
return space(p[l],p[r]);
if(r-l==2)
return minBinary(minBinary(space(p[l],p[l+1]),space(p[l],p[r])),space(p[l+1],p[r]));
int half=(l+r)/2;
double min=minBinary(binarySlove(l,half,p),binarySlove(half+1,r,p));
double sqrtMin=sqrt(min);
int cnt=0;
for (int i=l;i<=r;i++)
if(points[i].x<points[half].x+sqrtMin&&points[i].x>points[half].x-sqrtMin)
assist[cnt++]=points[i];
sort(assist,assist+cnt,cmpy);
for (int i=0;i<cnt;i++)
for (int j=i+1;j<cnt;j++)
{
if(assist[j].y-assist[i].y>sqrtMin)
break;
min=minBinary(min,space(assist[i],assist[j]));
}
return min;
}
int main()
{
while(scanf("%d",&num)!=EOF&&num)
{
int min=0;
for (int i=0;i<num;i++)
{
scanf("%lf%lf",&(points[i].x),&(points[i].y));
}
sort(points,points+num,cmpx);
double result=binarySlove(0,num-1,points);
printf("%.2lf\n",sqrt(result)/2);
}
return 0;
}

24
HDOJ/1008_autoAC.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
int main()
{
int i,n,a[101],sum;
while(scanf("%d",&n),n)
{
sum=0; a[0]=0;
for(i=1;i<=n;i++)
scanf("%d",a+i);
for(i=0;i<n;i++)
{
if(a[i]<=a[i+1])
{
sum+=(a[i+1]-a[i])*6+5;
}
else if(a[i]>a[i+1])
{
sum+=(a[i]-a[i+1])*4+5;
}
}
printf("%d\n",sum);
}
return 0;
}

51
HDOJ/1009_autoAC.cpp Normal file
View File

@ -0,0 +1,51 @@
#include<stdio.h>
#include <memory.h>
#include<stdlib.h>
struct Exchange{
int room;
int javabean;
};
int cmp( const void *a , const void *b )
{
struct Exchange *c = (Exchange *)a;
struct Exchange *d = (Exchange *)b;
if (d->room*1.0/d->javabean > c->room*1.0/c->javabean)
return 1;
else if (d->room*1.0/d->javabean < c->room*1.0/c->javabean)
return -1;
else return 0;
}
double summation(Exchange* ex,int len,int javabeans)
{
double sum=0;
qsort(ex,len,sizeof(Exchange),cmp);
for(int i=0;i<len;i++)
{
if(javabeans-ex[i].javabean>0)
{
sum+=ex[i].room;
javabeans-=ex[i].javabean;
}
else
{
sum+=javabeans*1.0/ex[i].javabean*ex[i].room;
break;
}
}
return sum;
}
int main()
{
int m,n;
while(scanf("%d%d",&m,&n)!=EOF)
{
if(m==-1&&n==-1)
break;
Exchange* e=new Exchange[n];
for(int i=0;i<n;i++)
scanf("%d%d",&(e[i].room),&(e[i].javabean));
double result=summation(e,n,m);
printf("%.3lf\n",result);
}
return 0;
}

83
HDOJ/1010_autoAC.cpp Normal file
View File

@ -0,0 +1,83 @@
#include<stdio.h>
#include<math.h>
int time,atx,aty,n,m;
char map[26][26];
bool flag;
void dfs(int x,int y,int t)
{
if(x<0||x>=n||y<0||y>=m)
return;
if(flag==true||(t==0&&x==atx&&aty==y))
{
flag=true;
return;
}
int temp=t-abs(x-atx)-abs(y-aty);
if(temp<0 || temp&1)
return;
map[x][y]='X';
if(map[x+1][y]!='X')
{
dfs(x+1,y,t-1);
if(flag)
return;
}
if(map[x][y+1]!='X')
{
dfs(x,y+1,t-1);
if(flag)
return;
}
if(map[x-1][y]!='X')
{
dfs(x-1,y,t-1);
if(flag)
return;
}
if(map[x][y-1]!='X')
{
dfs(x,y-1,t-1);
if(flag)
return;
}
map[x][y]='.';
}
int main()
{
int i,j,x,y,wall;
while(scanf("%d%d%d",&n,&m,&time)&&(n!=0||m!=0||time!=0))
{
flag=false;
wall=0;
for(i=0;i<n;++i)
{
scanf("%s",map[i]);
for(j=0;j<m;++j)
{
if(map[i][j]=='S')
{
x=i;
y=j;
}
if(map[i][j]=='D')
{
atx=i;
aty=j;
}
if(map[i][j]=='X')
wall++;
}
}
dfs(x,y,time);
if(n*m-wall<=time)
{
printf("NO\n");
continue;
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}