1551
int main(void)
{
double R,r;
while(scanf("%lf%lf",&R,&r)!=EOF)
{
if(r>1)
r=1/r;
double low=0,high=R;
double s=PI*R*R*r/(1+r),l,result;
while(1)
{
l=(low+high)/2;
result=R*R*asin(l/R)-sqrt(R*R-l*l)*l;
if(abs(result-s)<0.00001)
break;
if(result>s)
high=l;
if(result<s)
low=l;
}
printf("%.2lf\n",2*l);
}
return 0;
}
/**************************************************************
Problem: 1551
User: liangrx06
Language: C++
Result: Wrong Answer
****************************************************************/
1552
int main()
{
int i, n;
int m[N], f[N];
while(scanf("%d", &n) != EOF)
{
m[1] = 1;
f[1] = 0;
m[2] = f[2] = 1;
for (i=3; i<=n; i++)
{
m[i] = (m[i-1] + f[i-1]) % M;
f[i] = (f[i-1] + m[i-2]) % M;
}
printf("%d\n", (m[n]+f[n]) % M);
}
return 0;
}
/**************************************************************
Problem: 1552
User: liangrx06
Language: C
Result: Accepted
Time:50 ms
Memory:912 kb
****************************************************************/
1553
int main()
{
double h, m;
double res;
while(scanf("%lf:%lf", &h, &m) != EOF)
{
h = (h+m/60)/12*360;
m = m/60*360;
res = h-m;
if (res < 0)
res = -res;
if (res > 180)
res = 360-res;
printf("%.2lf\n", res);
}
return 0;
}
/**************************************************************
Problem: 1553
User: liangrx06
Language: C
Result: Accepted
Time:0 ms
Memory:912 kb
****************************************************************/
1554(未完成)
1555
//加上了释放动态内存函数del
typedef struct node {
char str[N+1];
struct node *next;
} Str;
int search(Str *sub, char s[])
{
while (sub)
{
if (strcmp(sub->str, s) == 0)
return 1;
sub = sub->next;
}
return 0;
}
Str *insert(Str *sub, char s[])
{
Str *p = (Str *)malloc(sizeof(Str));
strcpy(p->str, s);
p->next = sub;
return p;
}
void del(Str *sub)
{
Str *p;
while (sub)
{
p = sub->next;
free(sub);
sub = p;
}
}
int main()
{
int i, j, n;
char s[N+1], s1[N+1];
Str *sub[N/2+1];
int count;
while(scanf("%s", s) != EOF)
{
count = 0;
memset(sub, 0, sizeof(sub));
n = strlen(s);
for (i=0; i<n; i++)
{
for (j=1; j<=(n-i)/2; j++)
{
strncpy(s1, s+i, j);
s1[j] = '\0';
if (strstr(s+i+j, s1))
{
if (search(sub[j], s1) == 0)
{
count ++;
sub[j] = insert(sub[j], s1);
}
}
else
break;
}
}
for (i=1; i<=n/2; i++)
del(sub[i]);
printf("%d\n", count);
}
return 0;
}
/**************************************************************
Problem: 1555
User: liangrx06
Language: C
Result: Accepted
Time:90 ms
Memory:1180 kb
****************************************************************/
1556-1557(未完成)