zoukankan      html  css  js  c++  java
  • BZOJ3884: 上帝与集合的正确用法

    题解:

    最近颓的有点儿过了。。。主要是人太弱有点悲伤。。。

    正经题解戳出题人吧:http://blog.csdn.net/popoqqq/article/details/43951401

    代码:

     1 #include<cstdio>
     2 #include<cstdlib>
     3 #include<cmath>
     4 #include<cstring>
     5 #include<algorithm>
     6 #include<iostream>
     7 #include<vector>
     8 #include<map>
     9 #include<set>
    10 #include<queue>
    11 #include<string>
    12 #define inf 1000000000
    13 #define maxn 10000000
    14 #define maxm 100000+5
    15 #define eps 1e-10
    16 #define ll long long
    17 #define pa pair<int,int>
    18 #define for0(i,n) for(int i=0;i<=(n);i++)
    19 #define for1(i,n) for(int i=1;i<=(n);i++)
    20 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
    21 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
    22 #define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
    23 #define mod 1000000007
    24 #define lch k<<1,l,mid
    25 #define rch k<<1|1,mid+1,r
    26 using namespace std;
    27 inline int read()
    28 {
    29     int x=0,f=1;char ch=getchar();
    30     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    31     while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();}
    32     return x*f;
    33 }
    34 int p[maxn+1],tot,f[maxn+1];
    35 bool v[maxn+1];
    36 inline void get()
    37 {
    38     f[1]=1;
    39     for2(i,2,maxn)
    40     {
    41         if(!v[i])p[++tot]=i,f[i]=i-1;
    42         for1(j,tot)
    43         {
    44             int k=i*p[j];
    45             if(k>maxn)break;
    46             v[k]=1;
    47             if(i%p[j])f[k]=f[i]*(p[j]-1);
    48             else {f[k]=f[i]*p[j];break;}
    49         }
    50     }
    51 }
    52 inline int power(int x,int y,int p)
    53 {
    54     int t=1;
    55     for(;y;y>>=1,x=(ll)x*x%p)
    56      if(y&1)t=(ll)t*x%p;
    57     return t;
    58 }
    59 inline int solve(int x)
    60 {
    61     if(x==1)return 0;
    62     int t=0,y=x;
    63     while((y&1)==0)y>>=1,t++;
    64     return (power(2,(solve(f[y])-t%f[y]+f[y])%f[y],y)<<t)%x;
    65 }
    66 int main()
    67 {
    68     freopen("input.txt","r",stdin);
    69     freopen("output.txt","w",stdout);
    70     get();
    71     int T=read();
    72     while(T--)printf("%d
    ",solve(read()));
    73     return 0;
    74 }
    View Code
  • 相关阅读:
    数据类面试题
    java二进制文件复制
    String源码
    集合类题目
    OBJ-C
    java文件(文件夹)操作
    java中输入方式Scanner和BufferedReader
    二次分发举例
    Eclipse常用快捷键
    c#获取新浪微博登录cookie
  • 原文地址:https://www.cnblogs.com/zyfzyf/p/4304371.html
Copyright © 2011-2022 走看看