Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
periaさんの最大素数大富豪素数探索プログラムにおける結果 9999888877776666555544443333222213131313131312121212111111101101010111199998888777766665555444433332222131313131313121212121111111011010101111 の「最大性」をチェックするコード. ただし、最大性において以下の仮定をおいている.(1) JOKERはすべて "13" をもちいる(すなわち、13は6枚使用) (2) 相手の手元カードは "A" のみ(すなわち、1は3枚使用) 参考:Periaさんのコード https://gist.github.com/peria/00e294247aa422…
#include <gmpxx.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<string> cards;
cards.push_back("10");
cards.push_back("1");
cards.push_back("10");
cards.push_back("10");
cards.push_back("10");
cards.push_back("11");
cards.push_back("1");
cards.push_back("1");
string base = "9999888877776666555544443333222213131313131312121212111111";
sort(cards.begin(), cards.end(), greater<string>());
do {
string value;
for (int i=0; i<cards.size(); i++)
{
value += cards[i];
}
value = base + value;
cout << value;
int ret = mpz_probab_prime_p(mpz_class(value.c_str()).get_mpz_t(), 100);
if (ret) {
cout << " (*)";
}
cout << endl;
} while(next_permutation(cards.begin(), cards.end(), greater<string>()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.