跳到正文

个人记录

floor.io

Hyr_lu约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年8月17日
收录
2026年8月17日
更新
2026年8月17日
篇幅
约 1 分钟

版本

  1. v1当前
C++
D想要吗。
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int f(int a,int b)
{
	int r=1;
	a%=mod;
	while(b)
    {
		if(b&1)r=r*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return r;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
	int T;
	cin>>T;
	int x=f(2,mod-2),y=f(24,mod-2);
	for(int i=1;i<=T;i++)
    {
		int n,a=1;
		cin>>n;
		if(n>=2)a=(a+(n%mod)*((n-1)%mod)%mod*x)%mod;
		if(n>=4)a=(a+(n%mod)*((n-1)%mod)%mod*((n-2)%mod)%mod*((n-3)%mod)%mod*y)%mod;
		cout<<"Case #"<<i<<": "<<a<<"\n";
	}
	return 0;
}

原文