Skip to content

Commit cc6675b

Browse files
committed
leetcode 2546
1 parent b066885 commit cc6675b

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
long long mod=1e9+7;
9+
10+
long long factorial(int n){
11+
long long ans=1;
12+
for(int i=1;i<=n;i++){
13+
ans*=i;
14+
ans%=mod;
15+
}
16+
return ans;
17+
}
18+
19+
20+
int solve(){
21+
int n;
22+
cin>>n;
23+
long long ans=(long long)n*(n-1);
24+
ans%=mod;
25+
ans=(ans*factorial(n))%mod;
26+
cout<<ans<<endl;
27+
return 0;
28+
}
29+
int main()
30+
{
31+
int testCase=1;
32+
cin>>testCase;
33+
while(testCase--){
34+
solve();
35+
}
36+
return 0;
37+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
typedef long long ll;
6+
const ll INF = 1e18;
7+
const ll mod1 = 1e9 + 7;
8+
const ll mod2 = 998244353;
9+
// Add main code here
10+
11+
class Solution
12+
{
13+
public:
14+
vector<vector<int>> sortTheStudents(vector<vector<int>> &score, int k)
15+
{
16+
sort(begin(score), end(score), [&](vector<int> a, vector<int> b)
17+
{ return a[k] > b[k]; });
18+
return score;
19+
}
20+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
typedef long long ll ;
6+
const ll INF=1e18;
7+
const ll mod1=1e9+7;
8+
const ll mod2=998244353;
9+
//Add main code here
10+
11+
class Solution
12+
{
13+
public:
14+
bool makeStringsEqual(string s, string target)
15+
{
16+
int one1=0,one2=0;
17+
one1=count(s.begin(),s.end(),'1');
18+
one2=count(target.begin(),target.end(),'1');
19+
if(one1==0 || one2==0){
20+
return s==target;
21+
}
22+
else{
23+
return true;
24+
}
25+
}
26+
};

0 commit comments

Comments
 (0)