日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CSUOJ 1525 Algebraic Teamwork

發布時間:2025/7/25 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CSUOJ 1525 Algebraic Teamwork 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Problem A

Algebraic Teamwork

The great pioneers of group theory and linear algebra want to cooperate and join their theories. In group theory, permutations – also known as bijective functions – play an important role. For a finite set A, a function σ : A → A is called a permutation of A if and only if there is some function ρ : A → A with σ(ρ(a)) = a and ρ(σ(a)) = a?? for all a ∈ A.

The other half of the new team – the experts on linear algebra – deal a lot with idempotent functions. They appear as projections when computing shadows in 3D games or as closure operators like the transitive closure, just to name a few examples. A function p : A → A is called idempotent if and only if p(p(a)) = p(a)????? for all a ∈ A.

To continue with their joined research, they need your help. The team is interested in non-idempotent permutations of a given finite set A. As a first step, they discovered that the result only depends on the set’s size. For a concrete size 1 ≤ n ≤ 105, they want you to compute the number of permutations on a set of cardinality n that are not idempotent.

Input

The input starts with the number t ≤ 100 of test cases. Then t lines follow, each containing the set’s size 1 ≤ n ≤ 105.

Output

Output one line for every test case containing the number modulo 1000000007 = (109 + 7) of non-idempotent permutations on a set of cardinality n.

Sample Input

Sample Output

3

1

2

2171

0

1

6425

?

解題:n!-1

1 #include <bits/stdc++.h> 2 #define LL long long 3 using namespace std; 4 const int maxn = 100010; 5 const int md = 1e9+7; 6 LL d[maxn]; 7 int main(){ 8 d[0] = 1; 9 for(int i = 1; i < maxn; ++i) 10 d[i] = (i%md*d[i-1])%md; 11 int x,ks; 12 scanf("%d",&ks); 13 while(ks--){ 14 scanf("%d",&x); 15 printf("%lld\n",(d[x]+md-1)%md); 16 } 17 return 0; 18 } View Code

?

轉載于:https://www.cnblogs.com/crackpotisback/p/4344895.html

總結

以上是生活随笔為你收集整理的CSUOJ 1525 Algebraic Teamwork的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。