zoukankan      html  css  js  c++  java
  • HDU 5597 GTW likes function 打表

    GTW likes function

    题目连接:

    http://acm.hdu.edu.cn/showproblem.php?pid=5596

    Description

    Now you are given two definitions as follows.

    f(x)=∑xk=0(−1)k22x−2kCk2x−k+1,f0(x)=f(x),fn(x)=f(fn−1(x))(n≥1)

    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. (1≤n,x≤1012)

    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

    Hint

    题意

    题解:

    一切反动派都是纸老虎

    打表之后很容易发现,f(x) = x+1

    于是这道题就很蠢了,直接输出phi(n+x+1)就好了

    代码

    #include<iostream>
    #include<stdio.h>
    using namespace std;
    
    
    long long phi(long long n)
    {
        long long tmp=n;
        for(long long i=2;i*i<=n;i++)
            if(n%i==0)
            {
                tmp/=i;tmp*=i-1;
                while(n%i==0)n/=i;
            }
        if(n!=1)tmp/=n,tmp*=n-1;
        return tmp;
    }
    
    int main()
    {
        long long n,x;
        while(scanf("%I64d%I64d",&n,&x)!=EOF)
            printf("%I64d
    ",phi(x+n+1));
        return 0;
    }
  • 相关阅读:
    抽象类和接口
    Thread线程
    ArrayList、Vector和LinkedList
    Java并发编程:Callable、Future和FutureTask
    java开发JDBC连接数据库代码
    @Async的简单用法总结
    微信/企业微信的分享功能
    IOS11 底部输入框被手机输入法遮住
    MySQL 数据库设计总结
    Java 多个文件压缩下载
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5042003.html
Copyright © 2011-2022 走看看