#include <stdio.h>
#include <string.h>
const int h1[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int h2[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int tra(char c) { return c - '0'; }
int main()
{
// freopen("in.txt","r",stdin);
int i, T, n, a0, yea, mon, day;
__int64 a, b, ans;
char ph[15];
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
a0 = 0;
scanf("%I64d%I64d", &a, &b);
for(i = 0; i < n; i ++)
{
scanf("%s", &ph);
yea = tra(ph[3]) * 1000 + tra(ph[4]) * 100 + tra(ph[5]) * 10 + tra(ph[6]);
mon = tra(ph[7]) * 10 + tra(ph[8]);
day = tra(ph[9]) * 10 + tra(ph[10]);
if(ph[6] == ph[7] && ph[7] == ph[8] && ph[8] == ph[9] && ph[9] == ph[10]) a0 ++;
else if((ph[7] - ph[6] == 1) && (ph[8] - ph[7] == 1) && (ph[9] - ph[8] == 1) && (ph[10] - ph[9] == 1) ) a0 ++;
else if((ph[6] - ph[7] == 1) && (ph[7] - ph[8] == 1) && (ph[8] - ph[9] == 1) && (ph[9] - ph[10] == 1) ) a0 ++;
else
{
if(yea >= 1980 && yea <= 2016)
{
if(mon >= 1 && mon <= 12)
{
if((yea % 400 == 0) || (yea % 4 == 0 && yea % 100 != 0))
{
if(day >= 1 && day <= h2[mon]) a0 ++;
}
else
{
if(day >= 1 && day <= h1[mon]) a0 ++;
}
}
}
}
}
ans = a0 * a + (n - a0) * b;
printf("%I64d\n", ans);
}
return 0;
#include <string.h>
const int h1[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int h2[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int tra(char c) { return c - '0'; }
int main()
{
// freopen("in.txt","r",stdin);
int i, T, n, a0, yea, mon, day;
__int64 a, b, ans;
char ph[15];
scanf("%d", &T);
while(T--)
{
scanf("%d", &n);
a0 = 0;
scanf("%I64d%I64d", &a, &b);
for(i = 0; i < n; i ++)
{
scanf("%s", &ph);
yea = tra(ph[3]) * 1000 + tra(ph[4]) * 100 + tra(ph[5]) * 10 + tra(ph[6]);
mon = tra(ph[7]) * 10 + tra(ph[8]);
day = tra(ph[9]) * 10 + tra(ph[10]);
if(ph[6] == ph[7] && ph[7] == ph[8] && ph[8] == ph[9] && ph[9] == ph[10]) a0 ++;
else if((ph[7] - ph[6] == 1) && (ph[8] - ph[7] == 1) && (ph[9] - ph[8] == 1) && (ph[10] - ph[9] == 1) ) a0 ++;
else if((ph[6] - ph[7] == 1) && (ph[7] - ph[8] == 1) && (ph[8] - ph[9] == 1) && (ph[9] - ph[10] == 1) ) a0 ++;
else
{
if(yea >= 1980 && yea <= 2016)
{
if(mon >= 1 && mon <= 12)
{
if((yea % 400 == 0) || (yea % 4 == 0 && yea % 100 != 0))
{
if(day >= 1 && day <= h2[mon]) a0 ++;
}
else
{
if(day >= 1 && day <= h1[mon]) a0 ++;
}
}
}
}
}
ans = a0 * a + (n - a0) * b;
printf("%I64d\n", ans);
}
return 0;
}
心得:握日,a,b,ans都是__int64型,本来都想放弃了。。。