sicily 1752

来源:互联网 发布:水果编曲软件多少钱 编辑:程序博客网 时间:2024/05/18 22:10
#include "iostream"#include "cmath"#include "map"using namespace std;bool is_primer(int n){if (n == 1)return false;int m = floor(sqrt(double (n)) + 0.5);for (int i = 2; i <= m; i++)if (n % i == 0)return false;return true;}int main(){map<int, int> m;map<int, int>::iterator pos;int count = 1;for (int i = 2; i < 1000000; i++){if (is_primer(i)){m.insert(pair<int, int> (i, count));count++;}}int W;while (cin >> W && W != -1){ pos = m.find(W); cout << pos->second << endl;}}

 
原创粉丝点击