1. 程式人生 > >PTA B1037 在霍格沃茨找零錢

PTA B1037 在霍格沃茨找零錢

#include<cstdio>
const int Galleon=17*29;
const int sickle=29;

int main(){
  int a1,b1,c1;
  int a2,b2,c2;
  
  scanf("%d.%d.%d",&a1,&b1,&c1);
  scanf("%d.%d.%d",&a2,&b2,&c2);
  int price=a1*Galleon+b1*sickle+c1;
  int money=a2*Galleon+b2*sickle+c2;
  int change=money-price;
  if(change<0){
    printf("-");
    change=-change;
  }
  printf("%d.%d.%d\n",change/Galleon,change%Galleon/sickle,change%sickle);
  return 0;
}