Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Codeforces/C++/1594A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include<bits/stdc++.h>
#define ll long long
usign namespace std;
int main(){
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
cout<<-n+1<<" "<<n<<"\n";
}
}
17 changes: 17 additions & 0 deletions Codeforces/C++/1594B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include<bits/stdc++.h>
#define ll long long
ll p = 1000000007;
using namepsace std;
int main(){
ll t,n,k,s,tmp;
cin>>t;
while(t--){
s=0;tmp=1;
cin>>n>>k;
while(k){
s=(s+(k&1)*tmp)%p;
k>>=1;tmp=(tmp*n)%p;
}
cout<<s<<'\n';
}
}
26 changes: 26 additions & 0 deletions Codeforces/C++/1594C.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include<bits/stdc++.h>
using namespace std;
char a[300010],c[5];
int main(){
int t;
cin>>t;
while(t--){
int n,ans=0;
cin>>n>>c>>(a+1);
for (int i=1;i<=n;i++){
ans=i;
for(int j=i;j<=n;j+=i)if(a[j]!=c[0])ans=0;
if(ans)break;
}
if(ans==1){
cout<<"0\n";
}
else if(ans>1){
cout<<"1\n"<<ans;
}
else{
cout<<"2\n"<<n-1<<" "<<n;
}
}
return 0;
}
55 changes: 55 additions & 0 deletions Codeforces/C++/1594D.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include <bits/stdc++.h>
using namespace std;

int n,m,fa[400005];
int sz[400005];

int find(int x){
if(fa[x]==x)return x;
return fa[x]=find(fa[x]);
}

void merge(int x,int y){
int fx=find(x),fy=find(y);
if(fx==fy)return;
sz[fy]+=sz[fx];
sz[fx]=0;
fa[fx]=fy;

}

int work(){
int ans=0;
for(int i=1;i<=n;i++){
if(find(i)==find(i+n))return -1;
ans+=max(sz[i],sz[i+n]);
}
return ans;
}

int main(){

int t;cin>>t;
while(t--){
cin>>n>>m;
for(int i=1;i<=2*n;i++){
sz[i]=i<=n;fa[i]=i;
}
for(int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
char s[20];
scanf("%s",s);
if(s[0]=='i'){
merge(x,y+n);
merge(x+n,y);
}
else{
merge(x,y);
merge(x+n,y+n);
}
}
printf("%d\n",work());
}
return 0;
}
11 changes: 11 additions & 0 deletions Codeforces/C++/1594E.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include<bits/stdc++.h>
using namespace std;
long long n,p,f[61];
p=1000000007;
int main(){
cin>>n;
f[0]=1;
for(int i=1;i<=n;i++)
f[i]=(4*f[i-1]*f[i-1])%p;
cout<<(6*f[n-1]*f[n-1])%p;
}