1: #include <stdio.h>
2: #include <stdlib.h>
3: #include <string.h>
4: #include <math.h>
5:
6: double fl(double x){
7: return(-log2(x)/5+1);
8: }
9:
10: void lc(double len, char *s){
11: if(len<=(fl(12)-fl(16))/2+fl(16)){
12: strcpy(s, "16");
13: }else if(len<=(fl(8)-fl(12))/2+fl(12)){
14: strcpy(s, "16.");
15: }else if(len<=(fl(6)-fl(8))/2+fl(8)){
16: strcpy(s, "8");
17: }else if(len<=(fl(4)-fl(6))/2+fl(6)){
18: strcpy(s, "8.");
19: }else if(len<=(fl(3)-fl(4))/2+fl(4)){
20: strcpy(s, "4");
21: }else if(len<=(fl(2)-fl(3))/2+fl(3)){
22: strcpy(s, "4.");
23: }else if(len<=(fl(1.5)-fl(2))/2+fl(2)){
24: strcpy(s, "2");
25: }else if(len<=(1-fl(1.5))/2+fl(1.5)){
26: strcpy(s, "2.");
27: }else if(len<=1){
28: strcpy(s, "1");
29: }
30: }
31:
32: int rd(double a){
33: char buf[10], *s;
34: int b;
35:
36: sprintf(buf, "%lf", a);
37:
38: s=strchr(buf, '.');
39: if(s==NULL) return((int)a);
40: s++;
41:
42: if(*s-'0'<4) b=a;
43: else b=a+1;
44:
45: return(b);
46: }
47:
48: void strshift(char *s, int a, int b){
49: int i, l;
50:
51: l=strlen(s);
52: s[l+1]==NULL;
53: for(i=l; i>=a; i--){
54: s[i]=s[i-1];
55: }
56: }
57:
58: void pc(double pit, char *s){
59: int p;
60: pit*=40.0;
61: p=rd(pit)%12;
62: if(p<=1){
63: strcpy(s, "c");
64: }else if(p<=2){
65: strcpy(s, "c#");
66: }else if(p<=3){
67: strcpy(s, "d");
68: }else if(p<=4){
69: strcpy(s, "d#");
70: }else if(p<=5){
71: strcpy(s, "e");
72: }else if(p<=6){
73: strcpy(s, "f");
74: }else if(p<=7){
75: strcpy(s, "f#");
76: }else if(p<=8){
77: strcpy(s, "g");
78: }else if(p<=9){
79: strcpy(s, "g#");
80: }else if(p<=10){
81: strcpy(s, "a");
82: }else if(p<=11){
83: strcpy(s, "a#");
84: }else if(p<=0){
85: strcpy(s, "b");
86: }
87: p=rd(pit)/12;
88: if(p==0){
89: strshift(s, 1, 1);
90: s[1]='1';
91: }else if(p==2){
92: toupper(s[0]);
93: }
94: }
95:
96: main(){
97: double len, pit;
98: char a[8], b[4];
99:
100: while(fscanf(stdin, "%lf %lf", &len, &pit)!=EOF){
101: lc(len, a);
102: pc(pit, b);
103: printf("%s\n", strcat(a,b));
104: }
105: }