2017多校1 1006Function

本文介绍了一种算法,用于解决给定两个排列数组时如何计算满足特定条件的不同函数数量的问题。通过寻找数组中的环并利用这些环的特性进行计算,最终得出答案。

Function

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1530    Accepted Submission(s): 720


Problem Description
You are given a permutation a from 0 to n1 and a permutation b from 0 to m1.

Define that the domain of function f is the set of integers from 0 to n1, and the range of it is the set of integers from 0 to m1.

Please calculate the quantity of different functions f satisfying that f(i)=bf(ai) for each i from 0 to n1.

Two functions are different if and only if there exists at least one integer from0 to n1 mapped into different integers in these two functions.

The answer may be too large, so please output it in modulo 109+7.
 

Input
The input contains multiple test cases.

For each case:

The first line contains two numbers n,m.(1n100000,1m100000)

The second line contains n numbers, ranged from 0 to n1, the i-th number of which represents ai1.

The third line contains m numbers, ranged from 0 to m1, the i-th number of which represents bi1.

It is guaranteed that n106,m106.
 

Output
For each test case, output "Case #x:y" in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.
 

Sample Input
3 2 1 0 2 0 1 3 4 2 0 1 0 2 3 1
 

Sample Output
Case #1: 4 Case #2: 4
 


给2组数求不同函数关系的种类,根据题目的意思,就是求2组数列中不同环的数量,因为根据多对一的关系,将第二个数组中将 是第一个数组中不用数量的环的因子数的环相加,再最终将结果相乘即可。可以用vector容器来存不同数量的环



#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<queue>
#include<vector>
using namespace std;
const long long int MOD=7+1e9;
vector<int> al,bl;
int a[111111],b[111111];
bool v[111111];
int main(){
    int n,m;
    int cs=0;
    ios::sync_with_stdio(false);
    while(cin>>n>>m)
    {
        al.clear();
        bl.clear();
        int i;
        for(i=0;i<n;i++)
        cin>>a[i];
        for(i=0;i<m;i++)
        cin>>b[i];
        memset(v,0,sizeof(v));
        for(i=0;i<n;i++)
        {
            if(!v[i])
            {
                int now=a[i];
                int len=0;
                while(!v[now])
                {
                    v[now]=1;
                    len++;
                    now=a[now];
                }
                al.push_back(len);
            }
        }
        memset(v,0,sizeof(v));
        for(i=0;i<m;i++)
        {
            if(!v[i])
            {
                int now=b[i];
                int len=0;
                while(!v[now])
                {
                    v[now]=1;
                    ++len;
                    now=b[now];
                }
                bl.push_back(len);
            }
        }
        int j;
        long long int ans=1;
        for(i=0;i<al.size();i++)
        {
            long long int ans1=0;
            for(j=0;j<bl.size();j++)
             if(al[i]%bl[j]==0)
              ans1=(ans1+bl[j])%MOD;
              ans=(ans*ans1)%MOD;
        }
        cout<<"Case #"<<++cs<<": ";
        cout<<ans%MOD<<endl;
    }
    return 0;
} 


ms <- fread('ieu-b-18-data.txt') oa<- fread('FingerOA.txt') |--------------------------------------------------| |==================================================| |--------------------------------------------------| |==================================================| > head(ms) SNP CHR BP effect_allele other_allele P EAF BETA <char> <int> <int> <char> <char> <num> <num> <num> 1: rs62637812 1 51803 C T 0.8003000 0.001000000 -0.01826580 2: rs2462492 1 54676 T C 0.7979001 0.001257814 -0.01501210 3: rs28599927 1 62271 G A 0.8190000 0.001634987 -0.01176900 4: rs201684885 1 66162 T A 0.8140000 0.001000000 -0.01775670 5: rs13328683 1 74681 T G 0.8177000 0.001687966 0.01166780 6: rs1251109649 1 91536 T G 0.9769000 0.001000000 -0.00250313 SE samplesize <num> <int> 1: 0.0722086 115803 2: 0.0586260 115803 3: 0.0514308 115803 4: 0.0754741 115803 5: 0.0506186 115803 6: 0.0864472 115803 > head(oa) SNP CHR BP effect_allele other_allele P EAF BETA <char> <int> <int> <char> <char> <num> <num> <num> 1: rs62637812 1 51803 C T 0.8003000 0.001000000 -0.01826580 2: rs2462492 1 54676 T C 0.7979001 0.001257814 -0.01501210 3: rs28599927 1 62271 G A 0.8190000 0.001634987 -0.01176900 4: rs201684885 1 66162 T A 0.8140000 0.001000000 -0.01775670 5: rs13328683 1 74681 T G 0.8177000 0.001687966 0.01166780 6: rs1251109649 1 91536 T G 0.9769000 0.001000000 -0.00250313 SE samplesize <num> <int> 1: 0.0722086 115803 2: 0.0586260 115803 3: 0.0514308 115803 4: 0.0754741 115803 5: 0.0506186 115803 6: 0.0864472 115803。我要做MAGMA 基因分析确定oa和ms的 MAGMA 基因分析,通过在标记之间正确掺入 LD 来识别效性基因,并检测标记效应 (P < 0.05/18,345 = 2.73 × 10–6) [43]. 进行了 MAGMA 基因集分析以研究先导 SNP 的生物功能 [43],最终测试了来自分子特征数据库 (MSigDB) 的 10,678 个基因集,包括精选基因集 (c2.all) 和 go 术语 (c5.bp、c5.cc 和 c5.mf) [44]。对所有测试的基因集进行 Bonferroni 正以避免假阳性 (P < 0.05/10,678 = 4.68 × 10–6).Metascape webtools (metascape.org) 进行了通路富集分析,以确定基于 MSigDB 的定位基因的功能 [44]。对 54 个 GTEx 组织 [45] 进行了全基因组组织特异性富集分析,以获得 PLACO 生成的全基因组效性结果。我们还计算了平均表达式 (log2转化的)在所有 54 个 GTEx 组织中 [45] 中所有已鉴定出的效性基因 [45],并通过每个组织中的差异表达基因 (DEG) 测试组织特异性(上调和下调的 DEGs 由 t 统计量的符号预先计算)。具体列出详细方法步骤和R语言代码(包括任何做分析可用到的软件和补充文件)。
03-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值