BZOJ 3209)

Source: Internet
Author: User

[Submit] [Status] [Discuss]
Description
Background
As we all know, for many years, huashen has abused various major OJ, OI, CF, TC ...... Of course, CH is also included.
Description
It's said that Hua Shen has come to give lectures again this day. As shown in the following example, there are super difficult questions ...... I am sorry again.
The question of huashen is:
Set sum (I) to represent the number of 1 in the binary representation of I. A positive integer N is given.
Sum (I), that is, the product of sum (1)-sum (N.


Input
A positive integer N.


Output
A number. The answer model is a value of 10000007.


Sample Input
Example 1

3


Sample Output
Sample output 1

2

HINT

 

For example 1, 1*1*2 = 2;

 

Data scope and conventions

 

For 100% of the data, N ≤ 10 ^ 15


Source
Original Memphis

[Submit] [Status] [Discuss]
Bytes


Okay ...... The starting range of this question is N <= 1015

Then I naively thought it was not water ^? Result ......

Okay ......

It will be discovered only after the data is sent ......

N <= 10 ^ 15

This is the only way to cheat a hacker like me ......

 


By various D ......

 


OK, so this is the digital statistics ......

Just learned ...... (Still learning this <-weak)


[Cpp]
# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <iostream>
# Include <algorithm>
# Include <functional>
# Include <cmath>
# Include <cctype>
Using namespace std;
# Define For (I, n) for (int I = 1; I <= n; I ++)
# Define Rep (I, n) for (int I = 0; I <n; I ++)
# Define Fork (I, k, n) for (int I = k; I <= n; I ++)
# Define ForD (I, n) for (int I = n; I --)
# Define Forp (x) for (int p = pre [x]; p = next [p])
# Define RepD (I, n) for (int I = n; I> = 0; I --)
# Define MAXN (100000)
# Define MAXL (50 + 10)
# Define F (10000007)
Int a [MAXN], len = 0;
Long C [MAXL] [MAXL];
Long n;
Long calc (int k)
{
Long ans = 0;
ForD (I, len)
{
If (a [I])
{
Ans + = C [I-1] [k];
K --;
}
If (k <0) return ans;
}
Return ans;
}
Long pow2 (long a, long B)
{
If (B = 0) return 1;
If (B = 1) return;
Long tmp = pow2 (a, B/2 );
Tmp = tmp * tmp % F;
If (B % 2) tmp = (tmp * a) % F;
Return tmp;
}
Int main ()
{
// Freopen ("flower1.in", "r", stdin );
// Freopen (". out", "w", stdout );
Rep (I, 50)
{
C [I] [0] = 1;
For (j, I) C [I] [j] = (C [I-1] [j] + C [I-1] [J-1]);
}
/*
Cout <pow2 (2,1001) <endl;
Int pp = 1;
For (I, 1001) pp = (pp * 2) % F; cout <pp;
*/
While (cin> n)
{
N ++; // cout <n <endl;
Len = 0;
While (n) {a [++ len] = n % 2; n/= 2 ;}
Long ans = 1; // cout <len <endl;
For (I, len) ans = (ans * pow2 (I, calc (I) % F;
Printf ("% lld \ n", ans );
};
Return 0;
}

# Include <cstdio>
# Include <cstdlib>
# Include <cstring>
# Include <iostream>
# Include <algorithm>
# Include <functional>
# Include <cmath>
# Include <cctype>
Using namespace std;
# Define For (I, n) for (int I = 1; I <= n; I ++)
# Define Rep (I, n) for (int I = 0; I <n; I ++)
# Define Fork (I, k, n) for (int I = k; I <= n; I ++)
# Define ForD (I, n) for (int I = n; I --)
# Define Forp (x) for (int p = pre [x]; p = next [p])
# Define RepD (I, n) for (int I = n; I> = 0; I --)
# Define MAXN (100000)
# Define MAXL (50 + 10)
# Define F (10000007)
Int a [MAXN], len = 0;
Long C [MAXL] [MAXL];
Long n;
Long calc (int k)
{
Long ans = 0;
ForD (I, len)
{
If (a [I])
{
Ans + = C [I-1] [k];
K --;
}
If (k <0) return ans;
}
Return ans;
}
Long pow2 (long a, long B)
{
If (B = 0) return 1;
If (B = 1) return;
Long tmp = pow2 (a, B/2 );
Tmp = tmp * tmp % F;
If (B % 2) tmp = (tmp * a) % F;
Return tmp;
}
Int main ()
{
// Freopen ("flower1.in", "r", stdin );
// Freopen (". out", "w", stdout );
Rep (I, 50)
{
C [I] [0] = 1;
For (j, I) C [I] [j] = (C [I-1] [j] + C [I-1] [J-1]);
}
/*
Cout <pow2 (2,1001) <endl;
Int pp = 1;
For (I, 1001) pp = (pp * 2) % F; cout <pp;
*/
While (cin> n)
{
N ++; // cout <n <endl;
Len = 0;
While (n) {a [++ len] = n % 2; n/= 2 ;}
Long ans = 1; // cout <len <endl;
For (I, len) ans = (ans * pow2 (I, calc (I) % F;
Printf ("% lld \ n", ans );
};
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.