彪悍的翻译的代码,贴上以供仰慕
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[]={6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int da[2][12]={{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int y, m, d, n;
scanf("%4d%2d%2d%d", &y, &m, &d, &n); //这样快速拆分数据QAQ
bool flag=0;
int ans=0;
while(true)
{
int sum=0;
sum+=a[d%10]+a[d/10]+a[m%10]+a[m/10]+a[y/1000]+a[(y%1000)/100]+a[(y%100)/10]+a[y%10];
if(sum==n)
{
flag=1;
printf("%d\n", ans);
break;
}
if(y==2999 && m==12 && d==31)
break;
d++;
ans++;
if(d>da[((y%4==0 && y%100) || y%400==0)][m-1])
d=1, m++;
if(m>12)
m=1, y++;
}
if(!flag)
{
puts("-1");
}
}
return 0;
}