两个简单题,但都是几遍才过的- -
3600 Taxi Fare
杭州公交涨价了,不过没关系,反正坐的少。当时新老价格不是分开算的,所以出现了舍入问题。
#include <stdio.h>
int main()
{
int T;
int d, t;
double o, n;
scanf("%d", &T);
while(T --)
{
scanf("%d%d", &d, &t);
if(d <= 3)
o = n = 11;
else if(d <= 10)
{
o = 11+2*(d-3);
n = 11+2.5*(d-3);
}
else
{
o = 25+3*(d-10);
n = 28.5+3.75*(d-10);
}
o += 2.0*t/5;
n += 2.5*t/4;
printf("%d\n", (int)(n+0.5)-(int)(o+0.5));
}
return 0;
}
3603 Draw Something Cheat
忘记一个字符要多次输出。。
#include <cstdio>
#include <cstring>
unsigned char count[26];
unsigned char cnt[26];
int main()
{
int T, N;
char s[13];
scanf("%d", &T);
while(T --)
{
memset(count, 0xff, 26);
scanf("%d", &N);
while(N --)
{
scanf("%s", s);
memset(cnt, 0, 26);
for(int i=0; i<12; ++i)
++ cnt[s[i]-'A'];
for(int i=0; i<26; ++i)
if(cnt[i] < count[i])
count[i] = cnt[i];
}
for(int i=0; i<26; ++i)
while(count[i] --)
printf("%c", i+'A');
printf("\n");
}
return 0;
}