QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207148#5749. Directed Vertex Cactic20231020AC ✓24ms159988kbC++238.4kb2023-10-08 10:23:042023-10-08 10:23:05

Judging History

你现在查看的是最新测评结果

  • [2023-10-08 10:23:05]
  • 评测
  • 测评结果:AC
  • 用时:24ms
  • 内存:159988kb
  • [2023-10-08 10:23:04]
  • 提交

answer

/*
膜拜传奇特级宗师 Afterglow 大神儿
今天在 florr 首页称您为大夏尊贵的大名儿
一股敬佩之情油生然而
您在 florr 为国争光,扬我大夏威名
向您献上最真挚的膜拜!!!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
*/
/*
          _____                    _____                     _____                    _____
         /\    \                  /\    \                   /\    \                  /\    \
        /  \    \                /  \    \                 /  \____\                /  \    \
        \   \    \              /    \    \               /   /    /                \   \    \
         \   \    \            /      \    \             /   /    /                  \   \    \
          \   \    \          /   /\   \    \           /   /____/                    \   \    \
           \   \    \        /   /  \   \    \         /    |    |                     \   \    \
            \   \    \      /   /    \   \    \       /     |    |                      \   \    \
             \   \    \    /   /    / \   \    \     /      |    |                       \   \    \
              \   \    \  /   /    /   \   \    \   /       |____|__ _____                \   \    \
_______________\   \____\/   /____/     \   \    \ /   /|            \    \ _______________\   \____\
\                  /    /\   \    \      \   \    \\  / |    _________\____\\                  /    /
 \    ____________/____/  \   \    \      \   \____\\/__|   |    |           \    ____________/____/
  \   \    \               \   \    \     |   |    |    |   |    |            \   \    \
   \   \    \               \   \    \    |   |    |    |   |    |             \   \    \
    \   \    \               \   \    \   |   |____|    |   |    |              \   \    \
     \   \    \               \   \    \  /   /    /    \   |    |               \   \    \
      \   \    \               \   \    \/   /    /      \  |    |                \   \    \
       \   \____\               \   \___/   /    /        \ |    |                 \   \____\
        \  /    /                \         /    /          \|    |                  \  /    /
         \/____/                  \_______/____/            \____|                   \/____/
*/
#define poj
#define zcz
#ifdef poj
//C++
#include<iomanip>
#include<iostream>
//C
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
//STL
#include<algorithm>
#include<bitset>
#include<functional>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
//C++11
#if __cplusplus>=201103L
#include<chrono>
#include<random>
#include<unordered_set>
#include<unordered_map>
#endif
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#ifdef zcz
class fastin{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *inf;
	char *inbuf,*inst,*ined;
	inline char _getchar(){
		if(inst==ined)inst=inbuf,ined=inbuf+fread(inbuf,1,MAXBF,inf);
		return inst==ined?EOF:*inst++;
	}
	public:
	fastin(FILE*_inf=stdin){
		inbuf=new char[MAXBF],inf=_inf,inst=inbuf,ined=inbuf;
	}
	~fastin(){delete[]inbuf;}
	template<typename Int> fastin&operator>>(Int &n){
		static char c;
		Int t=1;
		while((c=_getchar())<'0'||c>'9')if(c=='-')t=-1;
		n=(c^48);
		while((c=_getchar())>='0'&&c<='9')n=n*10+(c^48);
		n*=t;
		return *this;
	}
	fastin&operator>>(char&c){
		while((c=_getchar())<'!'||c>'~');
		return *this;
	}
	fastin&operator>>(char*s){
		int t=0;
		static char c;
		while((c=_getchar())==' '||c=='\n');
		s[t++]=c;
		while((c=_getchar())>='!'&&c<='~')s[t++]=c;
		s[t]='\0';
		return *this;
	}
}fi;
class fastout{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *ouf;
	char *oubuf,*oust,*oued;
	inline void _flush(){fwrite(oubuf,1,oued-oust,ouf);oued=oust;}
	inline void _putchar(char c){
		if(oued==oust+MAXBF)_flush(),oued=oubuf;
		*oued++=c;
		#ifdef local
		_flush();
		#endif
	}
	public:
	fastout(FILE*_ouf=stdout){
		oubuf=new char[MAXBF],ouf=_ouf,oust=oubuf,oued=oubuf;
	}
	~fastout(){_flush();delete[]oubuf;}
	template<typename Int> fastout&operator<<(Int n){
		if(n<0)_putchar('-'),n=-n;
		static char S[20];
		int t=0;
		do{S[t++]='0'+n%10,n/=10;}while(n);
		for(int i=0;i<t;++i)_putchar(S[t-i-1]);
		return *this;
	}
	fastout&operator<<(char c){_putchar(c);return *this;}
	fastout&operator<<(char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
	fastout&operator<<(const char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
}fo;
#define cin fi
#define cout fo
#else
#define czc ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#endif
#define mod7 1000000007
#define mod9 998244353
#define ll long long
#define isinf 0x3f3f3f3f
#define ilinf 0x7fffffff
#define lsinf 0x3f3f3f3f3f3f3f3f
#define llinf 0x7fffffffffffffff
#define pii pair<int,int>
#define fr first
#define sc second
#define next ___
#define pb push_back
#define N 500010
#define M 5000010
#define For(i,a,b) for(ll i=(a);i<=(b);++i)
#define Rep(i,a,b,c) for(ll i=(a);i<=(b);i+=c)
#define Per(i,a,b,c) for(ll i=(a);i>=(b);i-=c)
#define Gra(i) for(ll i=h[x];i;i=next[i])
typedef int arr[N];
typedef int arm[M];
typedef ll arl[N];
typedef ll alm[M];
typedef double ard[N];
typedef double adm[M];
namespace modint{
	template<typename Int,Int mod,Int m1>
	struct modint{
		Int v;
		modint(){v=0;}
		modint(Int a){v=a;}
		bool operator==(modint a){return v==a.v;}
		bool operator!=(modint a){return v!=a.v;}
		bool operator<(modint a){return v<a.v;}
		bool operator>(modint a){return v>a.v;}
		bool operator<=(modint a){return v<=a.v;}
		bool operator>=(modint a){return v>=a.v;}
		bool operator==(Int a){return v==a;}
		bool operator!=(Int a){return v!=a;}
		bool operator<(Int a){return v<a;}
		bool operator>(Int a){return v>a;}
		bool operator<=(Int a){return v<=a;}
		bool operator>=(Int a){return v>=a;}
		friend bool operator==(Int a,modint b){return b==a;}
		friend bool operator!=(Int a,modint b){return b!=a;}
		friend bool operator<(Int a,modint b){return b>a;}
		friend bool operator>(Int a,modint b){return b<a;}
		friend bool operator<=(Int a,modint b){return b>=a;}
		friend bool operator>=(Int a,modint b){return b<=a;}
		modint operator+(modint a){return v>=mod-a.v?v-mod+a.v:v+a.v;}
		modint operator-(modint a){return v>=a.v?v-a.v:v+mod-a.v;}
		modint modnum(modint a){
			return a-((__int128(a.v)*m1)>>80)*mod+0;
		}
		modint operator*(modint a){return modnum(v*a.v);}
		modint operator+=(modint a){*this=*this+a;return *this;}
		modint operator-=(modint a){*this=*this-a;return *this;}
		modint operator*=(modint a){*this=*this*a;return *this;}
		modint qpow(modint a,Int b){
			modint r(1);
			for(;b;b>>=1,a*=a)if(b&1)r*=a;
			return r;
		}
		modint operator/(modint a){return qpow(a,mod-2)*v;}
		modint operator/=(modint a){*this=*this/a;return *this;}
		modint&operator++(){*this=*this+1;return *this;}
		modint&operator--(){*this=*this-1;return *this;}
		const modint operator++(int){modint r=*this;++*this;return r;}
		const modint operator--(int){modint r=*this;--*this;return r;}
		friend modint operator+(Int a,modint b){return b+a;}
		friend modint operator-(Int a,modint b){return b-a;}
		friend modint operator*(Int a,modint b){return b*a;}
		friend modint operator/(Int a,modint b){return modint(a)/b;}
		#ifdef cout
		friend fastin&operator>>(fastin&in,modint&n){in>>n.v;return in;}
		friend fastout&operator<<(fastout&out,modint n){out<<n.v;return out;}
		#else
		friend istream&operator>>(istream&in,modint&n){in>>n.v;return in;}
		friend ostream&operator<<(ostream&out,modint n){out<<n.v;return out;}
		#endif
	};
	typedef modint<long long,1000000007,1208925811152148> int7;
	typedef modint<__int128,1000000009,(__int128(1)<<80)/1000000009> int9;
}
using namespace modint;
ll n,m,p;
int9 f[M],in[M];
int9 c(ll n,ll m){
	int9 r=1;
	For(i,n-m+1,n)r*=i;
	return r*in[m];
}
void solve(){
	cin>>n>>m;p=max(n,m);
	f[0]=1;
	For(i,1,p)f[i]=f[i-1]*i;
	in[p]=int9(1)/f[p];
	Per(i,p,1,1)in[i-1]=in[i]*i;
	cout<<f[n]*c(n*(n-1)/2,m);
	return;
}
int main(){
	#ifndef zcz
	czc;
	#endif
	int t=1;
	while(t--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 159968kb

input:

3 1

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 3ms
memory: 159960kb

input:

4 4

output:

360

result:

ok 1 number(s): "360"

Test #3:

score: 0
Accepted
time: 3ms
memory: 159960kb

input:

39847 348708

output:

983575456

result:

ok 1 number(s): "983575456"

Test #4:

score: 0
Accepted
time: 4ms
memory: 159956kb

input:

1 1

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 11ms
memory: 159848kb

input:

3 2

output:

18

result:

ok 1 number(s): "18"

Test #6:

score: 0
Accepted
time: 0ms
memory: 159908kb

input:

3 3

output:

6

result:

ok 1 number(s): "6"

Test #7:

score: 0
Accepted
time: 7ms
memory: 159920kb

input:

3 4

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 23ms
memory: 159920kb

input:

3 1000000

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 11ms
memory: 159924kb

input:

4 1

output:

144

result:

ok 1 number(s): "144"

Test #10:

score: 0
Accepted
time: 7ms
memory: 159904kb

input:

4 2

output:

360

result:

ok 1 number(s): "360"

Test #11:

score: 0
Accepted
time: 11ms
memory: 159960kb

input:

4 3

output:

480

result:

ok 1 number(s): "480"

Test #12:

score: 0
Accepted
time: 13ms
memory: 159904kb

input:

4 5

output:

144

result:

ok 1 number(s): "144"

Test #13:

score: 0
Accepted
time: 3ms
memory: 159920kb

input:

4 6

output:

24

result:

ok 1 number(s): "24"

Test #14:

score: 0
Accepted
time: 3ms
memory: 159920kb

input:

5 1

output:

1200

result:

ok 1 number(s): "1200"

Test #15:

score: 0
Accepted
time: 3ms
memory: 159972kb

input:

5 2

output:

5400

result:

ok 1 number(s): "5400"

Test #16:

score: 0
Accepted
time: 3ms
memory: 159824kb

input:

5 3

output:

14400

result:

ok 1 number(s): "14400"

Test #17:

score: 0
Accepted
time: 8ms
memory: 159892kb

input:

5 4

output:

25200

result:

ok 1 number(s): "25200"

Test #18:

score: 0
Accepted
time: 8ms
memory: 159896kb

input:

5 5

output:

30240

result:

ok 1 number(s): "30240"

Test #19:

score: 0
Accepted
time: 7ms
memory: 159908kb

input:

5 6

output:

25200

result:

ok 1 number(s): "25200"

Test #20:

score: 0
Accepted
time: 7ms
memory: 159988kb

input:

5 7

output:

14400

result:

ok 1 number(s): "14400"

Test #21:

score: 0
Accepted
time: 0ms
memory: 159964kb

input:

5 8

output:

5400

result:

ok 1 number(s): "5400"

Test #22:

score: 0
Accepted
time: 0ms
memory: 159900kb

input:

5 9

output:

1200

result:

ok 1 number(s): "1200"

Test #23:

score: 0
Accepted
time: 4ms
memory: 159844kb

input:

5 10

output:

120

result:

ok 1 number(s): "120"

Test #24:

score: 0
Accepted
time: 0ms
memory: 159840kb

input:

1000 1

output:

533396879

result:

ok 1 number(s): "533396879"

Test #25:

score: 0
Accepted
time: 3ms
memory: 159840kb

input:

1000 100

output:

199484478

result:

ok 1 number(s): "199484478"

Test #26:

score: 0
Accepted
time: 7ms
memory: 159844kb

input:

1000 10000

output:

656650652

result:

ok 1 number(s): "656650652"

Test #27:

score: 0
Accepted
time: 23ms
memory: 159904kb

input:

1000 1000000

output:

0

result:

ok 1 number(s): "0"

Test #28:

score: 0
Accepted
time: 16ms
memory: 159836kb

input:

535164 619302

output:

721871396

result:

ok 1 number(s): "721871396"

Test #29:

score: 0
Accepted
time: 24ms
memory: 159904kb

input:

1000000 1000000

output:

580712335

result:

ok 1 number(s): "580712335"

Test #30:

score: 0
Accepted
time: 15ms
memory: 159892kb

input:

1000000 234534

output:

546630669

result:

ok 1 number(s): "546630669"

Test #31:

score: 0
Accepted
time: 21ms
memory: 159900kb

input:

234523 1000000

output:

127869098

result:

ok 1 number(s): "127869098"

Test #32:

score: 0
Accepted
time: 11ms
memory: 159980kb

input:

44722 10000

output:

0

result:

ok 1 number(s): "0"