本文整理汇总了C++中rational::pden方法的典型用法代码示例。如果您正苦于以下问题:C++ rational::pden方法的具体用法?C++ rational::pden怎么用?C++ rational::pden使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rational
的用法示例。
在下文中一共展示了rational::pden方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
int shift = 20;
hashset hset;
hashset::iterator iter;
i64 mup = (1LL<<(2*shift))-1;
i64 mdown = (1LL<<shift)-1;
mup -= mdown;
vector<rational> vr;
for(int di = 2; di <= 35; ++di)
for(int ni = 1; ni < di; ++ni){
int common = gcd(ni, di);
if(common> 1) continue;
vr.push_back(rational(ni, di));
}
sort(vr.begin(), vr.end());
for(unsigned int i = 0; i < vr.size(); ++i){
for(unsigned int j = i; j < vr.size(); ++j){
rational& r1 = vr[i];
rational& r2 = vr[j];
const rational xr = r1 + r2;
//x+y=z
if(xr.pnum() >= xr.pden()) break;
if(xr.pden() <= 35){
rational xr2 = xr + xr;
i64 value = (xr2.pden()<<shift)+(xr2.pnum());
assert(((value & mup)>>shift) == xr2.pden());
assert((value & mdown) == xr2.pnum());
iter = hset.find(value);
if(iter == hset.end()){
hset.insert(value);
//printf("a %lld %lld %lld %lld %lld %lld %lld %lld\n", r1.pnum(), r1.pden(),
// r2.pnum(), r2.pden(), xr.pnum(), xr.pden(), xr2.pnum(), xr2.pden());
}
}
}
}