Alice and Bob have not finished writing

Source: Internet
Author: User

Alice and Bob timelimit:1 Sec Memory limit:64 MB
submit:255 solved:43

Descriptionalice is a beautiful and clever girl. Bob would like-to-play with Alice. One day, Alice got a very big rectangle and wanted to divide it into small square pieces. Now comes a problem:if all pieces of small squares is of the same size, how big could the squares is? To Alice, it's easy to solve the problem. However, she is very busy, so she asked Bob to help her. You know Alice was such a lovely girl and of course Bob won ' t refuse her request. But Bob isn't so smart and he's especially weak in math. So he turns to you-a genius at programming. Alice would inform Bob the length and width of the big rectangle, and Bob has to tell her the longest length for the small Square. All of these numbers is in their binary representations. Inputthe first line of the input is a positive integer. This is the number of the the test cases followed. Each test case contains a their binary representation which tells you the length and width of the ver Y Big Rectangle (0< L , W < 2^1000). There may is one or several spaces between these integers. Outputthe output of the program should consist of one line of output for each test case. The output of each test case is contains the longest length for the small squares in its binary representation. No any redundant spaces is needed. Sample Input
2100 1000100 110
Sample Output
10010

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void mult (int p[],int *len1)
{
int i;
for (i=0;i<*len1;i++)
{
p[i]*=2;
P[I+1]+=P[I]/10;
p[i]%=10;
printf ("p[%d]=%d\n", I,p[i]);
}
if (P[i])
(*LEN1) + +;
}

Void Add (int p[],int q[],int *len1)
{
    int i;
    for (i=0;i<*len1;i++)
    {
        P[i]+=q[i];
        if (p[i]>9)
        {
            p[i]-=10;
            p[i+1]++;
       }
   }
    if (p[i])
       (*LEN1) + +;
}


int main ()//transfer binary to dimcal, convey double "length, decimal array"
{
Freopen ("A.txt", "R", stdin);
int n,i,j;
Char str1[1001];
Char str2[1001];
int num_a[1000];
int num_b[1000];
int num_c[1000]; Two times out of the beginning
int len1,len2;

scanf ("%d", &n);

while (n--)
{
scanf ("%s", str1);
scanf ("%s", str2);

Len2=len1=1;
memset (num_a,0,sizeof (num_a));
memset (num_b,0,sizeof (Num_b));
memset (num_c,0,sizeof (Num_c));

for (i=0;str1[i]!= ' n '; i++)
{
num_c[0]=str1[i]-' 0 ';
Mult (NUM_A,&AMP;LEN1); by 2
Add (NUM_A,NUM_C,&AMP;LEN1);
}
for (i=0;str2[i]!= ' n '; i++)
num_a[i]=str2[i]-' 0 ';
}
return 0;
}


Alice and Bob have not finished writing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.