/ Randle /

记录详情

Compile Error

/in/foo.cc: In function 'double c(int, int)':
/in/foo.cc:9:48: error: invalid operands of types 'double' and 'double' to binary 'operator%'
     for(int i=2;i<=m;i++)sa=(sa+log((double)i))%mod;
                             ~~~~~~~~~~~~~~~~~~~^~~~
/in/foo.cc:10:48: error: invalid operands of types 'double' and 'double' to binary 'operator%'
     for(int i=2;i<=n;i++)sb=(sb+log((double)i))%mod;
                             ~~~~~~~~~~~~~~~~~~~^~~~
/in/foo.cc:11:50: error: invalid operands of types 'double' and 'double' to binary 'operator%'
     for(int i=2;i<=n-m;i++)sc=(sc+log((double)i))%mod;
                               ~~~~~~~~~~~~~~~~~~~^~~~
/in/foo.cc: In function 'int main()':
/in/foo.cc:18:22: error: invalid operands of types 'double' and 'double' to binary 'operator%'
     cout<<exp(c(m,n))%mod;
           ~~~~~~~~~~~^~~~

代码

#include<iostream>
#include<cmath>
using namespace std;
double mod=1000000007;
double c(int m,int n)
{
    double sa,sb,sc;
    sa=sb=sc=0.0;
    for(int i=2;i<=m;i++)sa=(sa+log((double)i))%mod;
    for(int i=2;i<=n;i++)sb=(sb+log((double)i))%mod;
    for(int i=2;i<=n-m;i++)sc=(sc+log((double)i))%mod;
    return sb-sa-sc;
}
int main()
{
    int m,n;
    cin>>m>>n;
    cout<<exp(c(m,n))%mod;
    return 0;
}

信息

递交者
类型
递交
题目
电影 T1
题目数据
下载
语言
C++
递交时间
2017-10-02 17:59:29
评测时间
2017-10-05 16:21:07
评测机
分数
0
总耗时
386ms
峰值内存
31.43 MiB