吃了11個WA還是解不出來,而先前也有不少人跟我一樣錯line: 2
有大大知道怎麼解決比較好嗎?XD
以下是開始亂改前的正常程式碼XD
#include <iostream> #include <iomanip> #include <string> #include <cmath> using namespace std; #define pi 3.1415926 int main() { string times; int degree, Ndegree; double radian, Nradian, buffer1, buffer2, cosnx, cosx, sinnx, sinx; while (cin >> times >> degree, times != "0") { degree %= 360, radian = degree * pi / 180, Ndegree = 0; for (int i = 0; i != times.size(); i++) Ndegree *= 10, Ndegree += int(times[i] - '0'), Ndegree %= 360; Nradian = ((Ndegree * degree) % 360) * pi / 180; cosnx = cos(Nradian), cosx = cos(radian), sinnx = sin(Nradian), sinx = sin(radian); buffer1 = -0.5 * sinnx + (sinx - sinx * cosnx) / (2. - 2 * cosx); buffer2 = sinx * sinnx / (2. - 2 * cosx) + 0.5 - 0.5 * cosnx; printf("%.4f\n", buffer1 * cosx + buffer2 * sinx); } }
話說,這種有浮點數的題目真的很難出耶
一不小心就會演變成,不少人在那邊調誤差,看看能不能AC,尤其是有公式題的(難以推導的公式更明顯)XD