日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

题目1440:Goldbach's Conjecture(哥达巴赫猜想)

發布時間:2023/12/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 题目1440:Goldbach's Conjecture(哥达巴赫猜想) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:http://ac.jobdu.com/problem.php?pid=1440

?

詳解鏈接:https://github.com/zpfbuaa/JobduInCPlusPlus

?

參考代碼:

// // 1440 Goldbach's Conjecture.cpp // Jobdu // // Created by PengFei_Zheng on 12/04/2017. // Copyright ? 2017 PengFei_Zheng. All rights reserved. // #include <stdio.h> #include <iostream> #include <algorithm> #include <string.h> #include <cmath>using namespace std;bool isPrime(long long n){// here n is no less than 4, so we don't need to consider 2、3long long x = sqrt(n)+1;for(long long i = 2 ; i <= x ; i ++){if(0 == n % i) return false;}return true; }long long n;int main(){while(scanf("%lld",&n)!=EOF && n!=0){int counter = 0;// beacuse n is even, so 2 can never being included// in order to reduce the calculation numbers, just need to reverse to n/2// therefore start with 3 and i+=2for(int i = 3 ; i <= n/2 ; i+=2){if(isPrime(i) && isPrime(n-i)){counter++;}}printf("%d\n",counter);}return 0; } /**************************************************************Problem: 1440User: zpfbuaaLanguage: C++Result: AcceptedTime:40 msMemory:1532 kb ****************************************************************/

?

轉載于:https://www.cnblogs.com/zpfbuaa/p/6701440.html

總結

以上是生活随笔為你收集整理的题目1440:Goldbach's Conjecture(哥达巴赫猜想)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。