#20481: 算出規律但有誤差,用python也算了一樣的答案


fdhs109_31813 (username)

學校 : 桃園市私立復旦高級中學
編號 : 103932
來源 : [140.112.25.14]
最後登入時間 :
2024-04-26 21:20:38
d096. 00913 - Joana and the Odd Numbers -- UVa913 | From: [118.167.104.236] | 發表日期 : 2020-01-29 15:53

#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<sstream>
#include<cstdlib>
#include<cctype>
using namespace std;

int main()
{
double d;
while (cin >> d)
{
cout << static_cast<unsigned long long>(3.0 / 2 * d * d + 3 * d - 15.0 / 2) << endl;
}
}

#0: 50% WA (line:2)

您的答案為: 706647194196847488
正確答案為: 706647194196847485
 
#20486: Re:算出規律但有誤差,用python也算了一樣的答案


wanttogo0718@gmail.com (Hello World)

學校 : 國立高雄師範大學
編號 : 86382
來源 : [42.75.43.186]
最後登入時間 :
2021-05-21 22:56:38
d096. 00913 - Joana and the Odd Numbers -- UVa913 | From: [27.247.190.36] | 發表日期 : 2020-01-30 12:55

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;

int main()
{
double d;
while (cin >> d)
{
cout << static_cast(3.0 / 2 * d * d + 3 * d - 15.0 / 2) << endl;
}
}

#0: 50% WA (line:2)

您的答案為: 706647194196847488
正確答案為: 706647194196847485

算式有問題吧  我算是6 * d


 
#20487: Re:算出規律但有誤差,用python也算了一樣的答案


wanttogo0718@gmail.com (Hello World)

學校 : 國立高雄師範大學
編號 : 86382
來源 : [42.75.43.186]
最後登入時間 :
2021-05-21 22:56:38
d096. 00913 - Joana and the Odd Numbers -- UVa913 | From: [27.247.190.36] | 發表日期 : 2020-01-30 13:07

#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;

int main()
{
double d;
while (cin >> d)
{
cout << static_cast(3.0 / 2 * d * d + 3 * d - 15.0 / 2) << endl;
}
}

#0: 50% WA (line:2)

您的答案為: 706647194196847488
正確答案為: 706647194196847485

算式有問題吧  我算是6 * d


說錯了 算式沒問題,確實是誤差的關係
測資如下:


input:
686365885

output:
706647194196847485

 
#37302: Re: 算出規律但有誤差,用python也算了一樣的答案


mountainwu14@gmail.com (吳小四)

學校 : 不指定學校
編號 : 187101
來源 : [122.121.24.68]
最後登入時間 :
2023-12-11 22:56:32
d096. 00913 - Joana and the Odd Numbers -- UVa913 | From: [122.121.7.144] | 發表日期 : 2023-08-31 00:02

2023年,我用 python寫, 也是出現這個東西

#0: 50% WA (line:2)

您的答案為: 706647194196847488
正確答案為: 706647194196847485

請問考試遇到時,程式要如何修改
是因為整數不夠存嗎
 
ZeroJudge Forum