Пример #1
0
 void main()
{
 int data[N]={0};
 int i=0;
 int n=200000;
 time_t start,end;
 //printf("please input the number of data you wanna to test(should less than 100):\n");
 //scanf("%d",&n);
 if(n&1)
 {
  printf("sorry,the number should be even ");
  return;
 }
 for(i=0;i<n;i++)
  data[i]=i+1;
 time(&start);
 perfect(data,n);
 time(&end);
// for(i=0;i<n;i++)
 //  printf("%d   ",data[i]);
  printf("\n%d ",num);
  printf("\n%d ",start);
  printf("\n%d ",end);

}
main()
{
      system("color F0");
      system("title Numeros perfectos en un intervalo");
      int a,b,k;
      puts("Ingrese el inicio del intervalo");
      scanf("%d",&a);
      puts("Ingrese el final del intervalo");
      scanf("%d",&b);
      if(a > 0 && b >= a)
      {
         system("cls");
         for(k=a;k<=b;k++)
             perfect(k);
         if(z>1)
            printf("Hay %d numeros perfectos\n",z);
         else
            printf("Hay %d numero perfecto\n",z);
         system("pause > nul");
      }
      else
      {
          system("cls");
          puts("ERROR, Intervalo negativo, con 0 o el final menor que el inicio");
          system("pause > nul");
      }
}
Пример #3
0
void sol_q0()
{
    long long t;

    if (q != 0 || p < 0)
        return;

    if (perfect(p, &t)) {
        trysol(0, -t);
        trysol(0, t);
    }

    if ((p % 2) == 0 && perfect(p / 2, &t)) {
        trysol(-t, -t);
        trysol(t, t);
    }
}
Пример #4
0
int main()
{
	std::string str = "adddb";
	int sum = perfect(str);

	std::cout << "sum: " << sum << std::endl;

	return 0;
}
Пример #5
0
int main(void) {
    int num_draws = 200000;
    srand(time(0));
    int k = rand() % 1000000;  // Seed
    int i = 0;
    while (i < num_draws) {
        double p = perfect(k + i);
        printf("%g\n", p);
        i++;
    }
    return 0;
}
Пример #6
0
void sol_gen()
{
    long long d, t, x;

    if (q == 0)
        return;

    d = p * p + 6 * p * q + q * q;
    if (d < 0)
        return;

    if (!perfect(d, &d))
        return;

    t = p + 3 * q + d;
    if (t >= 0 && (t % 4) == 0 && perfect(t / 4, &x))
        tryx(x);

    t = p + 3 * q - d;
    if (t >= 0 && (t % 4) == 0 && perfect(t / 4, &x))
        tryx(x);
}
int main()
{
    int n,len,sum,extra,l;
    char a[300],b[300],c[300];
    scanf("%d",&n);
    getchar();
    while(n--)
    {
        scanf("%s %s",a,b);
        len1 = strlen(a);
        len2 = strlen(b);
        len = maxx()-1;
        i = 0;
        j = 0;
        l = 0;
        sum = 0;
        extra = 0;
        while(1)
        {
            if(i>len1-1)
                a[i] = '0';
            if(j>len2-1)
                b[j] = '0';
            sum = (a[i++]-'0')+(b[j++]-'0')+extra;
            if(sum>=10)
            {
                sum = sum - 10;
                extra = 1;
            }
            else
                extra = 0;
            c[l++] = sum + '0';
            if(l>len && extra == 0)
                break;
        }
        c[l] = '\0';
        perfect(c);
        memset(c,'\0',sizeof(c));
        printf("\n");
    }
    return 0;
}
Пример #8
0
int main()
{

    int a, b, c;

    printf("\nPlease enter your range of number: ");
    scanf("%d", &a);
    printf("The list of perfect number between 1 and  %d is\n", a);

    for (c = 1; c <= a; c++) {

	b = perfect(c);
	if (b == c) {
	    printf("%d\n", c);
	}

    }

    return 0;
}
Пример #9
0
Move com_move(Board* b, int max_depth, int time_ms)
{
    Move move;
    int score = 100;
    quiet = true;

    move = opening_move(b);
    if (move == INVALID_MOVE) {
	SearchResult r;
	if (b->turn() < 25)
	    r = search_negascout(b, max_depth, time_ms / 2, time_ms);
	else if (b->turn() < 27)
	    r = wld(b, 1000);
	else
	    r = perfect(b);
	move = r.first;
	score = r.second;
    }

    return move;
}
Пример #10
0
void TextureProjection::fitTexture (std::size_t width, std::size_t height, const Vector3& normal, const Winding& w,
		float s_repeat, float t_repeat)
{
	if (w.size() < 3) {
		return;
	}

	Matrix4 st2tex = m_texdef.getTransform((float) width, (float) height);

	// the current texture transform
	Matrix4 local2tex = st2tex;
	{
		Matrix4 xyz2st;
		basisForNormal(normal, xyz2st);
		matrix4_multiply_by_matrix4(local2tex, xyz2st);
	}

	// the bounds of the current texture transform
	AABB bounds;
	for (Winding::const_iterator i = w.begin(); i != w.end(); ++i) {
		Vector3 texcoord = matrix4_transformed_point(local2tex, (*i).vertex);
		aabb_extend_by_point_safe(bounds, texcoord);
	}
	bounds.origin.z() = 0;
	bounds.extents.z() = 1;

	// the bounds of a perfectly fitted texture transform
	AABB perfect(Vector3(s_repeat * 0.5, t_repeat * 0.5, 0), Vector3(s_repeat * 0.5, t_repeat * 0.5, 1));

	// the difference between the current texture transform and the perfectly fitted transform
	Matrix4 matrix(Matrix4::getTranslation(bounds.origin - perfect.origin));
	matrix4_pivoted_scale_by_vec3(matrix, bounds.extents / perfect.extents, perfect.origin);
	matrix4_affine_invert(matrix);

	// apply the difference to the current texture transform
	matrix4_premultiply_by_matrix4(st2tex, matrix);

	setTransform((float) width, (float) height, st2tex);
	m_texdef.normalise((float) width, (float) height);
}
Пример #11
0
int main( void ){
	int i;	
	for(i = 1; i < 1000; i++) {
		printf("%d is %d\n", i, perfect(i));
	}

        int a;
	for(a = 2; a < 75; a++) {
		printf("%d is %d\n", a, prime(a));	
	}
	
	int num1, num2, num3,num4;
	printf("Enter number:\n");
        scanf("%d",&num1,"\n");
        printf("Enter  2nd number:\n");
        scanf("%d",&num2,"\n");
       	printf("Reverse number of %d is %d\n", num1, revDigits(num1));
	printf("Reverse number of %d is %d\n", num2, revDigits(num2));
     
	
	


}	
Пример #12
0
int main(void)
{
   int num;                                                               /* Counter to test through the numbers 1 to 10000                      */
   int factor_count;                                                      /* Counter to test all factors possible factors of 'num'               */
   int flag;                                                              /* 'Boolean' use of an int - to alert whether number is perfect or not */
   int remaind;                                                           /* Remainder value when testing for factors with modulus operator      */

   intro();

   for (num = 1; num <= COUNT; num++)                                     /* Loop to test all numbers from 1 to 10000, inclusive                 */
   {
      flag = perfect(num);
      if (flag == 1)
      {
         for (factor_count = num - 1; 0 < factor_count; factor_count--)   /* Finds and prints all factors of 'num'                               */
         {                                                                /* then prints the the value of 'num'                                  */
            remaind = num % factor_count;
            if (remaind == 0)
            {
               printf("+ %d ", factor_count);
            }
            else
            {
               /* null statement */
            }
         }
         printf("= %d\n", num);
      }
      else                                                                /* A twirly is printed when 'flag' remains 0 value - i.e. the next     */
      {                                                                   /* perfect number is yet to be found                                   */
         twirly();
      }
   }
   printf(" \r");                                                         /* Clear the remaining '\' character once test loop finishes           */
   return(0);
}
Пример #13
0
int main(void) {
    unsigned i;
    for (i = 1; i <= MN; i++)
        perfect(i, mPrimes[i - 1]);
return 0;
}