dalao题解

# A HDU 5702 Solving Order

——————————————————————————————————————

# B HDU 5703 Desert

——————————————————————————————————————

# C HDU 5704 Luck Competition

——————————————————————————————————————
n（2~100）个人参加一个游戏，

#include <bits/stdc++.h>
using namespace std;
int vis[150];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
memset(vis,0,sizeof(vis));
int n;
scanf("%d",&n);
for(int i=1;i<=n-1;i++)
{
int x;
scanf("%d",&x);
vis[x]++;
}
double P=-1;
int output=-1;
for(int ans=100;ans>=0;ans--)
{
vis[ans]++;
int sum=0;
for(int j=0;j<=100;j++)
{
sum+=vis[j]*j;
}
double ave=sum;
ave=(ave/(double)n);
ave*=2;
ave=ave*1.0/3.0;
if(ans<=ave)
{
int pos;
for(int j=(int)ave;j>=0;j--)
{
if(vis[j]>0)
{
pos=j;
break;
}
}
if(pos==ans)
{
double pp=1/(double)vis[ans];
if(pp>P)
{
P=pp;
output=ans;
}
}
else
{
if(0>P)
{
P=0;
output=ans;
}
}
}
vis[ans]--;
}
printf("%d %.2f\n",output,P);
}
}

# D HDU 5705 Clock

——————————————————————————————————————

#include <bits/stdc++.h>
#define maxs 20002020
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;

#define abs(x) ((x)<0?-(x):(x))

int deg(int &h,int &m,int &s){
int hh = (h*60*60+m*60+s);
int mm = (h*60*60+m*60+s)*12;
hh %= 720*60;
mm %= 720*60;
int t = abs(hh-mm);
return min(t,720*60-t);
}

s++;
if(s == 60){
m++;
s=0;
}
if(m == 60) {
h++;
m=0;
}
if(h == 12){
h = 0;
}
}

int main(){
// h  1/720   1
// m  1/60    12
// s  1       720
int _ = 1,kcase=0;
int h,m,s,x,p,tp,th,tm,ts;
while(~scanf("%d:%d:%d",&h,&m,&s)){
scanf("%d",&x); x*=120;
p = deg(h,m,s);
while(true){
th=h,tm=m,ts=s;
tp = deg(h,m,s);
if(tp == x) break;
if(tp<x&&p>x){
h=th,m=tm,s=ts;
break;
}
if(x<tp&&p<x){
h=th,m=tm,s=ts;
break;
}
p=tp;
//            printf("%d:%d:%d  %d - %d\n",h,m,s,tp,x);
}

printf("Case #%d: %02d:%02d:%02d\n",++kcase,h,m,s);

}
return 0;
}

# E HDU 5706 GirlCat

——————————————————————————————————————

#include <bits/stdc++.h>
#define maxs 202002
using namespace std;
int ok;
int n,m;
char a[1005][1005];
int fx[4]={0,0,1,-1};
int fy[4]={1,-1,0,0};
void Dfs(int x,int y,int num)
{
if(num==0)if(a[x][y]!='g')return ;
if(num==1)if(a[x][y]!='i')return ;
if(num==2)if(a[x][y]!='r')return ;
if(num==3)if(a[x][y]!='l')return ;
if(num==3)
{
ok++;
return ;
}
for(int i=0;i<4;i++)
{
int xx=x+fx[i];
int yy=y+fy[i];
if(xx>=0&&x<n&&yy>=0&&yy<m)
{
Dfs(xx,yy,num+1);
}
}
}
void Dfs2(int x,int y,int num)
{
if(num==0)if(a[x][y]!='c')return ;
if(num==1)if(a[x][y]!='a')return ;
if(num==2)if(a[x][y]!='t')return ;
if(num==2)
{
ok++;
return ;
}
for(int i=0;i<4;i++)
{
int xx=x+fx[i];
int yy=y+fy[i];
if(xx>=0&&x<n&&yy>=0&&yy<m)
{
Dfs2(xx,yy,num+1);
}
}
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)scanf("%s",a[i]);
int output=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]=='g')
{
ok=0;
Dfs(i,j,0);
output+=ok;
}
}
}
printf("%d ",output);
output=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]=='c')
{
ok=0;
Dfs2(i,j,0);
output+=ok;
}
}
}
printf("%d\n",output);
}
}

# F HDU 5707 Combine String

——————————————————————————————————————

if(a[i1]==c[i+j1])f[i][j]()=f[i1][j];if(b[j1]==c[i+j1])f[i][j]()=f[i][j1];

#include<bits/stdc++.h>
typedef long long int LL;
using namespace std;

#define abs(x) ((x)>0?(x):-(x))

const int N = 100000+7;
const int M = 10000000+7;
/***************************************************/

char a[2222],b[2222],c[2222];

int f[2222][2222];

int main(){
while(~scanf("%s",a)){
scanf("%s",b);
scanf("%s",c);

int la=strlen(a);
int lb=strlen(b);
int lc=strlen(c);

if(lc!=la+lb){
puts("No");
continue;
}

memset(f,0,sizeof(f));
f[0][0]=1;

for(int i=0;i<=la;i++)for(int j=0;j<=lb;j++){
if(i==0&&j==0) continue;
if(i>0&&a[i-1]==c[i+j-1]) f[i][j] |=f[i-1][j];
if(j>0&&b[j-1]==c[i+j-1]) f[i][j] |=f[i][j-1];
}

puts(f[la][lb]?"Yes":"No");
}
return 0;
}


# G HDU 5708 Alice and Bob

——————————————————————————————————————

#include <bits/stdc++.h>
#define maxs 20002020
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;

#define abs(x) ((x)<0?-(x):(x))

int a[111][111],b[111][111];
void solve(){
int n = 20;
int m = 20;
int k =  4;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(a[i][j]==0){
a[i][j+1]=1;
a[i+1][j]=1;
a[i+k][j+k]=1;
}
}
}

for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
b[i][j]=b[i-1][j]+b[i][j-1]-b[i-1][j-1]+a[i][j];
}
}

for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++)
printf(" %d",a[i][j],i+j);
puts("");
}

return ;
}

int main(){
//    solve();
int _ = 1,q,k,n,m;
for(scanf("%d",&_);_--;){
scanf("%d%d",&q,&k);
for(int i=1;i<=q;i++){
scanf("%d%d",&n,&m);
if(n<m) swap(n,m);
int flag = m/(k+1);
if(k == 1){
if(n%2==0||m%2==0) puts("Alice");
else               puts("Bob");
}
else {
if(m%(k+1)==0||(m-flag+n)&1)  puts("Alice");
else               puts("Bob");
}
}
}
return 0;
}

# H HDU 5709 Claris Loves Painting

——————————————————————————————————————

claris的博客吧

# I HDU 5710 Digit-Sum

——————————————————————————————————————

a*S(n)==b*S(2n)
a,b的范围都在[1,100]
s(x)为x的所有位的和

s(2n)=2s(n)9L $s(2n) = 2s(n)-9L$_ Ln5 $L为n里面大于5的数字的个数$

a×s(n)=b×s(2n)=>a×s(n)=b×(2s(n)9L)=>(2ba)×s(n)=b×9L=>Ls(n)=2bab9

1. a=2b $a=2b$，则 L=0 $L=0$，S为任意值。可得最小的 n=1 $n=1$
2. a>2b $a>2b$，则 L<0 $L<0$，矛盾！则无满足的 n $n$，输出0$0$
3. a<2b $a<2b$ S=9bL2ba5L $S=\frac{9bL}{2b−a}≤5L$(至少有L个5)，即必须满足 b5a $b≤5a$，否则无满足的n，输出0。

# J HDU 5711 Ingress

——————————————————————————————————————
n（16）个点
m（n^2）条双向边
K（50）次hack机会

07-03 2134

02-03 1642
07-03 1083
12-05 1875
05-07 34
03-14 33
05-28 1万+