以下是我的代码
// https://www.patest.cn/contests/pat-a-practise/1058
#include<stdio.h>
int main()
{
int g1,s1,k1,sum1,g2,s2,k2,sum2,ans,g,s,k;
while(scanf("%d.%d.%d %d.%d.%d",&g1,&s1,&k1,&g2,&s2,&k2)!=EOF)
{
sum1 = g1*17*29 + s1*29 + k1;
sum2 = g2*17*29 + s2*29 + k2;
ans = sum1 + sum2;
g = ans /(17*29);
s = (ans / 29 )% 17;
k = ans % 29;
printf("%d.%d.%d\n",g,s,k);
}
return 0;
}
// https://www.patest.cn/contests/pat-a-practise/1058
#include<stdio.h>
int main()
{
int g1,s1,k1,sum1,g2,s2,k2,sum2,ans,g,s,k;
while(scanf("%d.%d.%d %d.%d.%d",&g1,&s1,&k1,&g2,&s2,&k2)!=EOF)
{
sum1 = g1*17*29 + s1*29 + k1;
sum2 = g2*17*29 + s2*29 + k2;
ans = sum1 + sum2;
g = ans /(17*29);
s = (ans / 29 )% 17;
k = ans % 29;
printf("%d.%d.%d\n",g,s,k);
}
return 0;
}