1037 在霍格沃茨找零钱 (20分)

#include 
using namespace std;
int main(){
    int p1,p2,p3,a1,a2,a3;
    scanf("%d.%d.%d %d.%d.%d",&p1,&p2,&p3,&a1,&a2,&a3);
    int p = p1*17*29 + p2*29 + p3;
    int a = a1*17*29 + a2*29 + a3;
    int sum = a-p; 
    int galleon = sum/(17*29);
    int sickle = sum%(17*29)/29;
    int knut = sum%(27*29)%29;
    if (sum>0) 
        printf("%d.%d.%d",galleon,sickle,knut);
    else
        printf("%d.%d.%d",galleon,-sickle,-knut);
    return 0;
}

你可能感兴趣的:(1037 在霍格沃茨找零钱 (20分))