DUTOJ-1205: The power of the Holy grail of the value _ large number Division

Source: Internet
Author: User

When I pulled out a curry stick, no grail could stand in front of me. The saber is a weapon of mass destruction owned by the Grail, and the saber is curious about the power of the curry stick in his hand, and he begins to observe the light particles that appear when the curry sticks are released. He believes that the strength of the curry rod and the number of light particles have a relationship. The number of light grains is a large integer
X, Shirong found that the value of the curry rod is exactly the Lowbit (x). That is, after converting X to 2, only the lowest digit of 1 and its subsequent 0 are retained, and the preceding content is removed, the 10 numbers represented, such as 6 (110) Lowbit 2 (10), 12 (1100) Lowbit 4 (100), The Lowbit of 20 (10100) is also 4 (100). There is no priest Lang how to use the computer, so the Lang would like to ask you to help calculate the strength of the curry stick, the power value may be very large, so you only need to output it in addition to the remainder of the 109+7.

String division, binary, counting the number of divisions made when the first remainder is 1

The code is as follows:

 #include <iostream> #include <stdio.h> #include <string> using namespace std; int Chuyitwo (string
    & num) {int jie=0;
    int len = Num.size ();
    int temp;
    int Yushu;
    if ((num[len-1]-' 0 ')% 2 = 0) {Yushu = 0;
    }else{Yushu = 1;
        for (int i=0;i<len;i++) {temp = num[i]-' 0 ';
        temp = jie*10;
        Jie = temp% 2;
        temp = TEMP/2;
    num[i]= temp + ' 0 ';

return Yushu;
    int main () {int t;
    String num;
    int flag = 1;
    scanf ("%d", &t);
        for (int i=0;i<t;i++) {flag = 1;
        cin>>num;
            while (Chuyitwo (num) ==0) {flag *= 2;
        Flag = flag% 1000000007;
    printf ("%d\n", flag);
return 0; }

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.