zoukankan      html  css  js  c++  java
  • hdu-5597 GTW likes function(欧拉函数+找规律)

    题目链接:

    GTW likes function

    Time Limit: 4000/2000 MS (Java/Others)   

     Memory Limit: 131072/131072 K (Java/Others)


    Problem Description
     
    Now you are given two definitions as follows.

    f(x)=xk=0(1)k22x2kCk2xk+1,f0(x)=f(x),fn(x)=f(fn1(x))(n1)

    Note that φ(n) means Euler’s totient function.(φ(n)is an arithmetic function that counts the positive integers less than or equal to n that are relatively prime to n.)

    For each test case, GTW has two positive integers — n and x, and he wants to know the value of the function φ(fn(x)).
     
    Input
     
    There is more than one case in the input file. The number of test cases is no more than 100. Process to the end of the file.

    Each line of the input file indicates a test case, containing two integers, n and x, whose meanings are given above. (1n,x1012)
     
    Output
     
    In each line of the output file, there should be exactly one number, indicating the value of the function φ(fn(x)) of the test case respectively.
     
    Sample Input
     
    1 1
    2 1
    3 2
     
    Sample Output
     
    2
    2
    2
     
    题意:
     
    给这么一个函数,问euler(fn(x))为多少;
     
    思路:
     
    发现f0(x)=x+1;fn(x)=f(fn-1(x))=f0(fn-1(x))=fn-1(x)+1=f0(x)+n=x+n+1;
    再就是O(sqrt(n))复杂度找到euler(x+n+1);
     
    AC代码:
     
    //#include <bits/stdc++.h>
    
    #include <iostream>
    #include <queue>
    #include <cmath>
    #include <map>
    #include <cstring>
    #include <algorithm>
    #include <cstdio>
    using namespace std;
    #define Riep(n) for(int i=1;i<=n;i++)
    #define Riop(n) for(int i=0;i<n;i++)
    #define Rjep(n) for(int j=1;j<=n;j++)
    #define Rjop(n) for(int j=0;j<n;j++)
    #define mst(ss,b) memset(ss,b,sizeof(ss));
    typedef long long LL;
    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const int inf=0x3f3f3f3f;
    
    template<class T> void read(T&num) {
        char CH; bool F=false;
        for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
        for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
        F && (num=-num);
    }
    int stk[70], tp;
    template<class T> inline void print(T p) {
        if(!p) { puts("0"); return; }
        while(p) stk[++ tp] = p%10, p/=10;
        while(tp) putchar(stk[tp--] + '0');
        putchar('
    ');
    }
    
    
    LL n,x;
    
    int main()
    {
            while(cin>>n>>x)
            {
                LL sum=n+x+1,ans;
                ans=sum;
                for(LL i=2;i*i<=n+x+1;i++)
                {
                    if(sum%i==0)
                    {
                        ans=ans/i*(i-1);
                        while(sum%i==0)sum/=i;
                    }
                }
                if(sum>1)ans=ans/sum*(sum-1);
                cout<<ans<<"
    ";
            }
    
        return 0;
    }
  • 相关阅读:
    Radian快速启动程序——利用鼠标快速启动程序
    true launch bar 完美运行版——快速启动工具
    Executor – 快速调出你的程序
    还你清爽桌面!运行精灵软件(快速启动工具)试用测评
    运行精灵视频使用教程
    35个Google开源项目,你知道几个?
    日系精品快速启动程序软件——nrLaunch
    推荐一个快速启动工具——运行精灵(命令搜索型快速启动软件)
    《众智科学》:博弈
    山东大学2021算法期末试题
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5576188.html
Copyright © 2011-2022 走看看