内的整数,Knut是[0, 29)区间内的整数。
输出格式:
在一行中用与输入同样的格式输出哈利应该被找的零钱。如果他没带够钱,那么输出的应该是负数。
输入样例1:
10.16.27 14.1.28
输出样例1:
3.2.1
输入样例2:
14.1.28 10.16.27
输出样例2:
-3.2.1
#include <iostream>
#include<cstdio>
using namespace std;
typedef struct Money{
int galleon,sickle,knut;
}Money;
Money compu(Money m1,Money m2)
{
Money result;
if(m1.knut>m2.knut)
{
result.knut=m2.knut+29-m1.knut;
m2.sickle=m2.sickle-1;
}
else
{
result.knut=m2.knut-m1.knut;
}
if(m1.sickle>m2.sickle)
{
result.sickle =m2.sickle+17-m1.sickle;
m2.galleon=m2.galleon-1;
}
else
{
result.sickle=m2.sickle-m1.sickle;
}
result.galleon=m2.galleon-m1.galleon;
return result;
}
int main()
{
Money m1,m2,result;
int cm1,cm2;
scanf("%d.%d.%d",&m1.galleon,&m1.sickle,&m1.knut);
scanf("%d.%d.%d",&m2.galleon,&m2.sickle,&m2.knut);
cm1=m1.galleon*17*29+m1.sickle*29+m1.knut;
cm2=m2.galleon*17*29+m2.sickle*29+m2.knut;
cm1<cm2?result=compu(m1,m2):result=compu(m2,m1);
if(cm1>cm2)cout<<"-";
cout<<result.galleon<<"."<<result.sickle<<"."<<result.knut<<endl;
return 0;
}