gym101243

A

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<set>
#define ll __int64
#define mod 100000000
#define N 5e6+10
#define M 1e
using namespace std;
int n,k;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d %d",&n,&k);
printf("%d\n",max((n*+k-)/k,)); return ;
}

C

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<set>
#define ll __int64
#define mod 100000000
#define N 5e6+10
#define M 1e
using namespace std;
int h,w;
int x[],y[];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int exm=;
scanf("%d %d",&h,&w);
if(h<=||w<=)
{
printf("0\n");
return ;
}
if(h%==){
for(int i=h-;i>=;i-=){
for(int j=;j<w;j++){
x[exm]=i;
y[exm]=j;
exm++;
}
if(i!=){
x[exm]=i-;
y[exm]=w-;
exm++;
}
}
}
else{
for(int i=h-;i>=;i-=){
for(int j=;j<w;j++){
x[exm]=i;
y[exm]=j;
exm++;
}
x[exm]=i-;
y[exm]=w-;
exm++;
}
for(int j=;j<w;j+=){
if(j!=w-){
x[exm]=;
y[exm]=j;
exm++;
x[exm]=;
y[exm]=j;
exm++;
x[exm]=;
y[exm]=j+;
exm++;
}
else{
x[exm]=;
y[exm]=j;
exm++;
x[exm]=;
y[exm]=j;
exm++;
}
}
}
printf("%d\n",exm);
for(int i=;i<exm;i++)
printf("%d %d\n",x[i],y[i]);
return ;
}

D

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<set>
using namespace std;
#define PI acos(-1.0)
typedef long long ll;
typedef pair<int,int> P;
const int maxn=1e4+,maxm=1e5+,inf=0x3f3f3f3f,mod=1e9+;
const ll INF=1e13+;
struct edge
{
int from,to;
int cost;
};
edge es[maxm];
priority_queue<P,vector<P>,greater<P> >que;
char s[];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
cin>>s;
int n=strlen(s);
int ans=;
for(int i=;i<n;i++)
{
if(s[i]=='E'&&(s[i-]=='N'||s[i-]=='S')) ans=(ans*)%mod;
else if(s[i]=='W'&&(s[i-]=='N'||s[i-]=='S')) ans=(ans*)%mod;
}
cout<<ans<<endl;
return ;
}

E

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<set>
#define ll __int64
#define mod 100000000
#define N 5e6+10
#define M 1e
using namespace std;
ll n,k,a[];
ll sum[];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%I64d %I64d",&n,&k);
sum[]=;
ll maxn=;
int pos;
for(ll i=; i<=n; i++)
{
scanf("%I64d",&a[i]);
sum[i]=sum[i-]+a[i];
if(maxn<a[i])
{
pos=i;
maxn=a[i];
}
}
ll l,r;
ll ans1,ans2;
l=n-+maxn;
r=sum[n];
ans1=max(0ll,k-pos+)/l;
ans2=max(0ll,k-sum[pos-])/r;
for(ll i=; i<=ans1; i++)
if(k>=(pos-+l*i)&&k<=(sum[pos-]+r*i))
{
printf("YES\n");
return ;
}
printf("KEK\n");
return ;
}

F

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int maxn=1e3+,maxm=1e6+,inf=0x3f3f3f3f,mod=1e9+;
const ll INF=1e13+;
struct edge
{
int from,to;
char ch;
};
edge es[maxm];
int pa[maxn];
int findset(int x)
{
return pa[x]==x?x:pa[x]=findset(pa[x]);
}
void unit(int x,int y)
{
int fx=findset(x),fy=findset(y);
if(fx<=fy) pa[fx]=fy;
else pa[fy]=fx;
}
int in[maxn],out[maxn];
int ans[maxn];
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n,k;
scanf("%d%d",&n,&k);
for(int i=; i<=n; i++) pa[i]=i;
memset(out,,sizeof(out));
memset(in,,sizeof(in));
for(int i=; i<=k; i++)
{
scanf("%d%c%d",&es[i].from,&es[i].ch,&es[i].to);
if(es[i].ch=='=') unit(es[i].from,es[i].to);
else
{
if(es[i].ch=='>') swap(es[i].from,es[i].to);
es[i].ch='<';
}
}
for(int i=; i<=k; i++)
{
if(es[i].ch=='=') continue;
out[findset(es[i].from)]++,in[findset(es[i].to)]++;
}
for(int i=; i<=n; i++)
if(in[i]&&out[i]) ans[i]=;
for(int i=; i<=k; i++)
{
if(es[i].ch=='=') continue;
if(ans[findset(es[i].from)]==) ans[findset(es[i].to)]=;
else if(ans[findset(es[i].to)]==) ans[findset(es[i].from)]=;
}
for(int i=; i<=n; i++)
{
if(ans[findset(i)]==) cout<<"B";
else if(ans[findset(i)]==) cout<<"R";
else if(ans[findset(i)]==) cout<<"W";
else cout<<"?";
}
cout<<endl;
return ;
}

G

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<set>
#define ll __int64
#define mod 100000000
#define N 5e6+10
#define M 1e
using namespace std;
int n;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d",&n);
int que[];
int jishu=;
for(int i=;i*i<=n;i++)
{
if(n%i==)
{
int flag=;
que[jishu++]=i;
while(n%i==)
{
flag++;
n/=i;
if(flag>)
{
printf("NO\n");
return ;
}
}
}
}
if(n>)
que[jishu++]=n;
if(jishu==)
printf("YES\n");
else
printf("NO\n");
return ;
}

H

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<bitset>
#include<set>
#define ll __int64
#define mod 100000000
#define N 5e6+10
#define M 1e
using namespace std;
int n;
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
scanf("%d",&n);
if(n<)
{
ll ans=;
for(int i=;i<=n;i++)
ans*=;
printf("%I64d\n",ans);
}
else
{
ll ans=;
for(int i=;i<=;i++)
ans*=;
printf("%I64d",ans);
for(int i=;i<=n;i++)
printf("");
printf("\n");
}
return ;
}

J

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int maxn=1e3+,maxm=1e6+,inf=0x3f3f3f3f,mod=1e9+;
const ll INF=1e13+;
struct edge
{
int from,to;
char ch;
};
edge es[maxm];
char num[maxn][];
vector<int>G[maxn];
int cy[maxn],vis[maxn];
bool dfs(int u)
{
for(int i=; i<G[u].size(); i++)
{
int v=G[u][i];
if(vis[v]) continue;
vis[v]=true;
if(cy[v]==-||dfs(cy[v]))
{
cy[v]=u;
return true;
}
}
return false;
}
int solve(int n)
{
int ret=;
memset(cy,-,sizeof(cy));
for(int i=; i<=n; i++)
{
memset(vis,,sizeof(vis));
if(dfs(i)) ret++;
}
return ret;
}
int main()
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n,m;
scanf("%d%d",&n,&m);
for(int i=; i<=n; i++) scanf("%s",num[i]);
for(int i=; i<=m; i++) scanf("%s",num[i+n]);
for(int i=; i<=n; i++)
{
for(int j=; j<=m; j++)
{
if(num[i][]+num[i][]+num[i][]==num[j+n][]+num[j+n][]+num[j+n][])
G[i].push_back(j+n);
if(num[i][]+num[i][]+num[i][]==num[j+n][]+num[j+n][]+num[j+n][])
G[i].push_back(j+n);
}
}
cout<<solve(n)<<endl;
for(int i=n+; i<=n+m; i++)
{
if(cy[i]==-)continue;
if(num[cy[i]][]+num[cy[i]][]+num[cy[i]][]==num[i][]+num[i][]+num[i][])
cout<<"AT"<<" "<<num[cy[i]]<<" "<<num[i]<<endl;
else if(num[i][]+num[i][]+num[i][]==num[cy[i]][]+num[cy[i]][]+num[cy[i]][])
cout<<"TA"<<" "<<num[i]<<" "<<num[cy[i]]<<endl;
}
return ;
}
05-08 15:34