Is that a kind of fetishism?
No, he is objectively a god.
Knowledge of the topic and exactly how a Mcdic God.
(Although there was still blowing the head)
Virtual open field play.
The opening seconds of the first AB. C actually almost did not do it, a little shame.
Open D. How does ...... Div. D 2 can be stuck in me, and I mentality collapse.
Transferred to E. This is not a problem woc sb it ......
Back to the liver D. Hu mouth thought out, but the mentality has been a collapse, with only a long, long time to play out.
Finally, only 20min when opening F. This ...... spicy chicken triple? do not care.
A
Violence can be simulated.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=0,f=0;
while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
return f?-x:x;
}
int l,r,cnt[10];
bool check(int x){
while(x) cnt[x%10]++,x/=10;
bool ans=true;
FOR(i,0,9) if(cnt[i]>=2) ans=false;
FOR(i,0,9) cnt[i]=0;
return ans;
}
int main(){
l=read();r=read();
FOR(i,l,r) if(check(i)) return printf("%d\n",i),0;
puts("-1");
}
B
Discovery \ (I \) row leftmost \ (\ min (a_i + 1 , m) \) column that has been determined what to fill, the \ (I \) column top \ (\ min (b_i + 1 , n) \) line is already determined what to fill in. Any remaining.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=1111,mod=1000000007;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=0,f=0;
while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
return f?-x:x;
}
int n,m,ans=1,mat[maxn][maxn];
int main(){
n=read();m=read();
FOR(i,1,n) FOR(j,1,m) mat[i][j]=-1;
FOR(i,1,n){
int x=read();
FOR(j,1,x){
if(mat[i][j]==0) return puts("0"),0;
mat[i][j]=1;
}
if(x!=m){
if(mat[i][x+1]==1) return puts("0"),0;
mat[i][x+1]=0;
}
}
FOR(j,1,m){
int x=read();
FOR(i,1,x){
if(mat[i][j]==0) return puts("0"),0;
mat[i][j]=1;
}
if(x!=n){
if(mat[x+1][j]==1) return puts("0"),0;
mat[x+1][j]=0;
}
}
// FOR(i,1,n){
// FOR(j,1,m) printf("%d ",mat[i][j]);
// puts("");
// }
FOR(i,1,n) FOR(j,1,m) if(mat[i][j]==-1) ans=2ll*ans%mod;
printf("%d\n",ans);
}
C
Consider the contribution of each quality factor, done.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010,mod=1000000007;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=0,f=0;
while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
return f?-x:x;
}
int x,num[maxn],len,ans=1;
ll n;
int calc(int x){
int ans=0;
ll pr=x;
while(true){
ans=(ans+n/pr)%(mod-1);
ll pre=pr;
pr*=x;
if(pr/pre!=x || pr>n) break;
}
return ans;
}
int qpow(int a,int b){
int ans=1;
for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
return ans;
}
int main(){
x=read();n=read();
for(int i=2;i*i<=x;i++) if(x%i==0){
num[++len]=i;
while(x%i==0) x/=i;
}
if(x>1) num[++len]=x;
FOR(i,1,len){
int x=num[i];
ans=1ll*ans*qpow(x,calc(x))%mod;
}
printf("%d\n",ans);
}
D
To be honest, very fairy.
Figure none, no clear solution.
From the point set 1, set 2 points, 3 points, respectively, optionally in a set point, there is certainly connected twenty-two sides.
Just wish to find a three-membered ring in the drawing, three points must be above a set point 1, a set of points 2, 3 a set of points, regardless of the order. If there is no three-membered ring, no solution.
For each point the rest of the \ (u \) , if \ (u \) and this point is not even one of these three sides, indicating that they are certainly at a point of focus. If these three points and a plurality of edge points are not connected, no solution.
Finally, check wave.
Time complexity \ (O (n) \)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=600060;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=0,f=0;
while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
return f?-x:x;
}
int n,m,el,head[maxn],to[maxn],nxt[maxn],u_fa[maxn],dep[maxn],fa[maxn],ans[maxn],q[maxn],h,r,cnt=0;
bool flag,nnn[4],vis[maxn],use[maxn];
inline void add(int u,int v){
to[++el]=v;nxt[el]=head[u];head[u]=el;
}
int getfa(int x){
return x==u_fa[x]?x:u_fa[x]=getfa(u_fa[x]);
}
void dfs(int u,int f){
dep[u]=dep[f]+1;fa[u]=f;
for(int i=head[u];i;i=nxt[i]){
int v=to[i];
if(v==f) continue;
if(dep[v]){
if(fa[fa[u]]==v && !flag){
ans[u]=1;ans[fa[u]]=2;ans[fa[fa[u]]]=3;
flag=true;
}
}
else dfs(v,u);
}
}
void dfs2(int u,int f,int x,int y){
vis[u]=true;
for(int i=head[u];i;i=nxt[i]){
int v=to[i];
if(v==f || (ans[v]!=x && ans[v]!=y)) continue;
if(!use[(i+1)/2]) cnt++,use[(i+1)/2]=true;
if(!vis[v]) dfs2(v,u,x,y);
}
}
bool check(int x,int y){
MEM(vis,0);
int cnt1=0,cnt2=0;
FOR(i,1,n){
if(ans[i]==x) cnt1++;
if(ans[i]==y) cnt2++;
}
cnt=0;
FOR(i,1,n) if(ans[i]==x){dfs2(i,0,x,y);break;}
return 1ll*cnt1*cnt2==cnt;
}
int main(){
n=read();m=read();
FOR(i,1,n) u_fa[i]=i;
FOR(i,1,m){
int u=read(),v=read();
add(u,v);add(v,u);
u=getfa(u);v=getfa(v);
u_fa[u]=v;
}
FOR(i,1,n) if(getfa(i)!=getfa(1)) return puts("-1"),0;
dfs(1,0);
if(!flag) return puts("-1"),0;
FOR(u,1,n){
if(ans[u]) continue;
nnn[1]=nnn[2]=nnn[3]=false;
for(int i=head[u];i;i=nxt[i]){
int v=to[i];
if(ans[v]) nnn[ans[v]]=true;
}
FOR(i,1,3) if(!nnn[i]){
if(ans[u]) return puts("-1"),0;
ans[u]=i;
}
if(!ans[u]) return puts("-1"),0;
}
if(!check(1,2) || !check(1,3) || !check(2,3)) return puts("-1"),0;
FOR(i,1,n) printf("%d ",ans[i]);
}
E
Simple binomial inversion.
Special first sentence \ (k = 1 \) . Suppose hereinafter \ (K \ GE 2 \) .
Set \ (f_ {i, j} \) is exactly \ (I \) line does not meet the requirements, just \ (J \) Number Scheme not meet the requirements of the column. Requirement is \ (F_ {0,0} \) .
Set \ (g_ {i, j} \) for all the options, selected \ (I \) line does not meet the requirements, \ (J \) of the number of columns and the program does not meet the requirements. It is obvious that \ (g_ {i, j} = \ binom {n} {i} \ binom {n} {j} (k-1) ^ {n ^ 2- (ni) (nj)} k ^ {( Ni) (NJ)} \) .
By definition, \ (G_ {I, J} = \ SUM \ limits_ {X = I} ^ n-\ SUM \ limits_ {Y = J} ^ n-\ Binom {X} {I} \ Binom {Y} {J} {X F_, Y} \) .
Binomial inversion, \ (F_ {I, J} = \ SUM \ limits_ {X} ^ = I n-\ SUM \ limits_ {J} = Y ^ n-\ Binom I {X} {} \ {Y} Binom J} {(-. 1) ^ {(XI) + (YJ)} G_ {X, Y} \) .
Time complexity \ (O (n-2 ^ \ log K) \) . It may be further optimized.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010,mod=1000000007;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
char ch=getchar();ll x=0,f=0;
while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
return f?-x:x;
}
int n,k,ans,fac[maxn],invfac[maxn];
int qpow(int a,ll b){
int ans=1;
for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) ans=1ll*ans*a%mod;
return ans;
}
int C(int n,int m){
return 1ll*fac[n]*invfac[m]%mod*invfac[n-m]%mod;
}
int main(){
n=read();k=read();
if(k==1) return puts("1"),0;
fac[0]=1;
FOR(i,1,n) fac[i]=1ll*fac[i-1]*i%mod;
invfac[n]=qpow(fac[n],mod-2);
ROF(i,n-1,0) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
FOR(i,0,n) FOR(j,0,n){
int sum=1ll*C(n,i)*C(n,j)%mod*qpow(k-1,1ll*n*n-1ll*(n-i)*(n-j))%mod*qpow(k,1ll*(n-i)*(n-j))%mod;
// printf("i=%d,j=%d,sum=%d\n",i,j,sum);
if((i+j)%2==0) ans=(ans+sum)%mod;
else ans=(ans-sum+mod)%mod;
}
printf("%d\n",ans);
}
F
On the way.