• bzoj-3288 3288: Mato矩阵(数论)


    题目链接:

    3288: Mato矩阵

    Time Limit: 10 Sec  Memory Limit: 128 MB

    Description

    Mato同学最近正在研究一种矩阵,这种矩阵有n行n列第i行第j列的数为gcd(i,j)。
    例如n=5时,矩阵如下:

    1 1 1 1 1
    1 2 1 2 1
    1 1 3 1 1
    1 2 1 4 1
    1 1 1 1 5

    Mato想知道这个矩阵的行列式的值,你能求出来吗?

    Input

    一个正整数n mod1000000007

    Output

    n行n列的Mato矩阵的行列式。

    Sample Input

    5

    Sample Output

    16
     
    题意:
     
    思路:
     
    进行行列变换后得到对角行列式,结果就是对角行列式的对角线上的积,变换后是欧拉函数值;
     
    AC代码:
     
    /**************************************************************
        Problem: 3288
        User: LittlePointer
        Language: C++
        Result: Accepted
        Time:572 ms
        Memory:5196 kb
    ****************************************************************/
     
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #include <bits/stdc++.h>
    #include <stack>
    #include <map>
      
    using namespace std;
      
    #define For(i,j,n) for(int i=j;i<=n;i++)
    #define mst(ss,b) memset(ss,b,sizeof(ss));
      
    typedef  long long LL;
      
    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('
    ');
    }
      
    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const int inf=1e9;
    const int N=1e5+20;
    const int maxn=1e6+4;
    const double eps=1e-12;
     
    int phi[maxn];
     
    inline LL solve(int le)
    {
        LL sum=1;
        for(int i=2;i<=le;i++)
        {
            if(!phi[i])
            {
                for(int j=i;j<=le;j+=i)
                {
                    if(!phi[j])phi[j]=j;
                    phi[j]=phi[j]/i*(i-1);
                }
            }
            sum=sum*phi[i]%mod;
        }
        return sum;
    }
     
    int main()
    {
        int n;
        read(n);
        cout<<solve(n)<<"
    ";
        return 0;
    }
    

      

  • 相关阅读:
    Ecshop支持用户名、邮箱或手机号码登录
    Ecshop模板在首页调用指定分类的热销、推荐、新品商品
    使用JQuery的全屏背景图片,自动适应各种屏幕和浏览器
    浏览器左下角提示网页上有错误解决方法
    设为首页、加入收藏
    Flash遮住Div的解决办法
    谷歌站内搜索的两种方式
    网页内插入百度、谷歌搜索引擎
    CSS透明滤镜
    Eclipse无Server或者Tomcat8.5解决办法
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5818807.html
Copyright © 2020-2023  润新知