sum=1/1^2+1/2^2+1/3^2+1/4^2+.........+1/n^2+......
並計算 sqrt(6*sum)
herrDeng網內搜尋

自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
請用CPU-Z軟體檢測Cache & Memory 註:快取(L1-L3: SRAM) 第一級快取(L1)–通常存取只需要幾個週期,通常是幾十個KB。 第二級快取(L2)–比L1約有2到10倍較高延遲性,通常是幾百個KB或更多。 第三級快取(L3)(不...
-
C++ DP速解難題leetcode 3363 Find the Maximum Number of Fruits Collected [Python解請進]
-
計算gcd(123456789,999999999)
-
需要練習的Java程式:
-
輸入字串s 輸入int x 輸出 x個s
-
Leetcode 342 Power of Four幾個C++一行解 [codes on Leetcode] https://leetcode.com/problems/power-of-four/solutions/7081839/9-ways-of-bit-manipula...
-
問int怎麼存-689這個數字。 int用4個bytes。 答案請用16進位表達。
33 則留言:
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main() {
cout<<"pi\n";
cout<<"Input n=";
unsigned n;
cin>>n;
double sum=0;
for(int i=1;i<=n;i++){
sum=sum+1/((double)i*i) ;
}
cout<<"ans>>"<<sqrt(6*sum)<<endl;
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "pi......\n";
cout << "Input n=";
unsigned n;
double sum=0;
cin >>n;
cout << n<<endl;
for(int i=1;i<=n;i++)
{
sum=sum+1/((double)i*i);
}
cout <<sqrt(6*sum);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi......\n";
cout << "Input n=";
unsigned n;
double sum=0;
cin >> n;
cout << n << endl;
for (int i=1;i<=n;i++)
{
sum = sum+1/((double)i*i);
}
cout << sqrt(6*sum);
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi...\n";
cout << "Input n=";
double sum = 0;
unsigned n;
cin >> n;
cout << n << endl;
for (int i=1;i<=n;i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6*sum);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main() {
unsigned n;
cin >> n;
cout << n<<endl;
double sum=0;
for (int i = 1; i <= n; i++)
{
sum +=1/((double)i*i);
}
cout << sqrt(6*sum);
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
unsigned n;
cout << "Compute pi.......\n";
cout << "Input n=";
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
unsigned n;
cout << "Compute pi.......\n";
cout << "Input n=";
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main() {
cout << "Compute pi....\n";
cout << "Input n=";
unsigned n;
cin >> n;
double sum = 0;
for (int i = 1; i <= n; i++) {
sum = sum + 1 / double(i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
double sum = 0;
unsigned n;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi.......\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "π=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec\n";
system("pause");
return 0;
}
#include <iostream>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<ctime>
using namespace std;
int main(){
cout << "Compute pi .....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
for (int i=1;i<=n;i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << sqrt(6 * sum)<<endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec \n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "pi......\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
for (int i = 1; i <= n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << setprecision(16) << "zata(2)=" << sum << endl;
cout <<sqrt(6*sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec\n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Iput n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i<=n; i++)
{
sum = sum + 1 / ((double)i*i);
}
cout << sqrt(6 * sum);
system("Pause");
return 0;
#include
#include
#include
#include
#include
using namespace std;
int main()
{
cout << "input n=";
unsigned n; cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
for (int i=1; i<=n;i++)
{
sum += 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "%=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec/n";
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>
using namespace std;
int main()
{
cout<< "pi........\n";
cout<< "Input n=";
unsigned n;
double sum=0;
cin>>n;
cout<<n<<endl;
unsigned begin=clock(),end;
for(int i=1;i<=n;i++)
{
sum=sum+1.0/((double)i*i);
}
cout <<sqrt(6*sum);
system("pause");
return 0;
}
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<ctime>
using namespace std;
int main()
{
cout << "Compute Pi......\n ";
cout << "Input n=";
cin >> n;
unsigned n;
double sum = 0;
for (int i = 1; i <= n; i++)
sum += 1.0 / ((double)i*i);
cout << setprecision(16) << "zeta(2)" << sum << endl;
cout << Pi << sum << endl;
end = clock();
cout << (end - begin / 1000.0 <<"sec\n")
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;
int main(){
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin =clock(), end;
double sum = 0;
for (int i = 1; i <= n; i++)
{
sum += + 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zera(2)=" << sum << endl;
cout << "π="<< sqrt(6 * sum)<<endl;
end = clock();
cout << (end - begin) / 1000.0 << " sec\n";
system("Pause");
return 0;
}
#include
#include
#include
using namespace std;
int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}
#include
#include
#include
using namespace std;
int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}
#include
#include
#include
using namespace std;
int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}
#include
#include
#include
using namespace std;
int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}
#include
#include
#include
using namespace std;
int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}
#include
#include
#include
using namespace std;
int main()
{
cout << "compute pi.....\n";
cout << "Input n=";
unsigned n;
double sum = 0;
cin >> n;
cout << n << endl;
for (int i = 1; i < n; i++)
{
sum = sum + 1.0 / ((double)i*i);
}
cout << sqrt(6*sum);
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
cout << "Compute pi.....\n";
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
double sum = 0;
for (int i = 1; i <= n; i++) {
sum += 1 / ((double)i*i);
}
cout << sqrt(6 * sum); sfas
system("Pause");
return 0;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>
using namespace std;
int main()
{
cout << "Input n=";
unsigned n;
cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum=0;
for (int i = 1; i <= n ; i++)
sum += 1.0 / ((double)i*i);
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "π=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec\n";
system("Pause");
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
#include
int main()
{
cout << "input n=";
unsigned n; cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
#pragma omp parallel for reduction(+ : sum)
for (int i=1; i<=n;i++)
{
sum += 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "%=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec/n";
system("Pause");
return 0;
}
#include
#include
#include
using namespace std;
int main() {
cout<<"pi\n";
cout<<"Input n=";
unsigned n;
cin>>n;
double sum=0;
for(int i=1;i<=n;i++){
sum=sum+1/((double)i*i) ;
}
cout<<"ans>>"<<sqrt(6*sum)<<endl;
system("Pause");
return 0;
}
#include
#include
#include
using namespace std;
int main() {
cout<<"pi\n";
cout<<"Input n=";
unsigned n;
cin>>n;
double sum=0;
for(int i=1;i<=n;i++){
sum=sum+1/((double)i*i) ;
}
cout<<"ans>>"<<sqrt(6*sum)<<endl;
system("Pause");
return 0;
}
#include
#include
#include
#include
#include
using namespace std;
#include
int main()
{
cout << "input n=";
unsigned n; cin >> n;
cout << n << endl;
unsigned begin = clock(), end;
double sum = 0;
#pragma omp parallel for reduction(+ : sum)
for (int i=1; i<=n;i++)
{
sum += 1.0 / ((double)i*i);
}
cout << setprecision(16) << "zeta(2)=" << sum << endl;
cout << "%=" << sqrt(6 * sum) << endl;
end = clock();
cout << (end - begin) / 1000.0 << "sec/n";
system("Pause");
return 0;
}
張貼留言