コード例 #1
0
 void DiscreteDepthDistortionModel::getBinSize(const size_t &width, const size_t &height, size_t &bin_width, size_t &bin_height) {
   double ratio = width / static_cast<double>(height);
   std::set<size_t> divisors = getDivisors(width);
   double ref_bin_width = 8;
   bin_width = getClosestToRef(divisors, ref_bin_width);
   divisors = getDivisors(height);
   double ref_bin_height = ref_bin_width / ratio;
   bin_height = getClosestToRef(divisors, ref_bin_height);
 }
コード例 #2
0
void getDivisors(int p, int acc){
	int i;
	if (p == fCount){
		count[acc]++;
		return;
	}

	getDivisors(p+1, acc);
	for (i = 0; i < mult[p]; i++){
		acc *= factors[p];
		getDivisors(p+1, acc);
	}
}
コード例 #3
0
ファイル: prob29.cpp プロジェクト: mathlover777/ProjectEuler
int main(){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	int p[a-1],x[a-1];
	c=getPrimeHash(p,a,x);
	int i,j;
	for(i=0;i<=c-1;i++){
		printf("\n%d",x[i]);
	}

	// for(i=0;i<c;i++){
	// 	d[i]=0;
	// }
	// getDivisors(49000,x,d);
	// for(i=0;i<c;i++){
	// 	printf("\n%d >>> %d",i+1,d[i]);
	// }
	int list[(a-1)*(b-1)][c],d[c];
	for(i=0;i<(a-1)*(b-1);i++){
		for(j=0;j<c;j++){
			list[i][j]=0;
		}
	}
	int count=0,acount=0,l,k,newflag,flag;
	for(i=2;i<=a;i++){
		for(l=0;l<c;l++){
			d[l]=0;
		}
		getDivisors(i,x,d);
		for(j=2;j<=b;j++){
			//printf("\n********* a = %d b = %d ********",i,j);
			for(l=0;l<c;l++){
				//printf("\n%d >>> %d",x[l],d[l]*j);
				list[count][l]=d[l]*j;
			}
			flag=0;
			for(l=0;l<count;l++){
				newflag=0;
				for(k=0;k<c;k++){
					if(list[l][k]!=list[count][k]){
						newflag=1;
						break;
					}
				}
				if(newflag==0){
					//old number!!!
					flag=1;
					break; 
				}
			}
			if(flag==0){
				acount++;
			}
			count++;
		}
	}
	printf("\n ANS = %d \n",acount);
}
コード例 #4
0
ファイル: p357.cpp プロジェクト: dgquintas/my-code-samples
bool test(int n){
    --n;
    // test that its two least significant digits are 01
    if( !(n & 0x1) && ( (n>>1) & 0x1) ){
        // factor
        std::vector<int> divs( getDivisors(n) );
        std::vector<int>::iterator it;
        for(it = divs.begin(); it != divs.end(); it++){
            if( !g_primes.isPrime(*it + n/(*it)) ){
                return false;
            }
        }
        return true;
    }
    else{
        return false;
コード例 #5
0
int main(void){
	int i;

	scanf("%d", &N);

	while (N--){
		int a;
		scanf("%d", &a);
		factorize(a);
		getDivisors(0, 1);
	}

	long long best = 0;
	for (i = 0; i < MAXARR; i++)
		if (count[i] > 1 && (long long) count[i] * i > best)
			best = (long long) count[i] * i;

	printf("%lld\n", best);

	return 0;
}