hdu5528 Count a * b

Count a * b

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 262    Accepted Submission(s): 132


Problem Description
Marry likes to count the number of ways to choose two non-negative integers  a and  b less than  m to make  a×b mod  m0.

Let's denote  f(m) as the number of ways to choose two non-negative integers  a and  b less than  m to make  a×b mod  m0.

She has calculated a lot of  f(m) for different  m, and now she is interested in another function  g(n)=m|nf(m). For example,  g(6)=f(1)+f(2)+f(3)+f(6)=0+1+4+21=26. She needs you to double check the answer.

hdu5528 Count a * b_第1张图片


Give you  n. Your task is to find  g(n) modulo  264.
 

Input
The first line contains an integer  T indicating the total number of test cases. Each test case is a line with a positive integer  n.

1T20000
1n109
 

Output
For each test case, print one integer  s, representing  g(n) modulo  264.
 

Sample Input
 
   
2 6 514
 

Sample Output
 
   
26 328194
 

Source
2015ACM/ICPC亚洲区长春站-重现赛(感谢东北师大)
 
hdu5528 Count a * b_第2张图片
#include
const int maxn=100001;
using namespace std;
bool bb[maxn];
int prim[maxn],tot,v[maxn],s[maxn],t[maxn],n;
void prepare(){
    bb[1]=1;v[1]=1;t[1]=1;
    for(int i=2;i<=maxn;i++){
        if(!bb[i]){
            prim[++tot]=i;
            v[i]=2*i-1;
            s[i]=1;
            t[i]=i;
        }
        for(int j=1;j<=tot&&prim[j]*i1){
        ans1*=(1LLU*n*n+1);
        ans2*=2*n;
    }
   //cout<


你可能感兴趣的:(我写的,hdu)