A
水题
检测是否为顺时针逆时针或同时符合
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define slld(n) scanf("%lld",&n)
#define slldd(n,m) scanf("%lld%lld",&n,&m)
#define sllddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define slf(n) scanf("%lf",&n)
#define slff(n,m) scanf("%lf%lf",&n,&m)
#define slfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define llans() printf("%lld",ans)
#define llanss() printf("%lld ",ans)
#define llansn() printf("%lld\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<v.size();++i)
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000000+7;
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const ll infl = 1e16;
const int maxn= 300+10;
const int maxm = 40000+10;
int in(int &ret)
{
char c;
int sgn ;
if(c=getchar(),c==EOF)return -1;
while(c!='-'&&(c<'0'||c>'9'))c=getchar();
sgn = (c=='-')?-1:1;
ret = (c=='-')?0:(c-'0');
while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
ret *=sgn;
return 1;
}
char ch[4]={'^','>','v','<'};
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif // LOCAL
char s[5],s2[5];
ss(s),ss(s2);
int t;
sd(t);
t%=4;
int idx =0 ;
while(ch[idx]!=s[0])idx++;
int a=0,b=0;
if(ch[ (idx+t)%4 ]==s2[0] )a=1;
int check = (idx-t+4)%4;
if(ch[ (idx-t+4)%4]==s2[0])b=1;
if(a&&!b)puts("cw");
else if(!a&&b)puts("ccw");
else puts("undefined");
return 0;
}
B
从后往前处理一下这个字母是不是最后一个
然后再按顺序更新一下此时打开的门数
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define slld(n) scanf("%lld",&n)
#define slldd(n,m) scanf("%lld%lld",&n,&m)
#define sllddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define slf(n) scanf("%lf",&n)
#define slff(n,m) scanf("%lf%lf",&n,&m)
#define slfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define llans() printf("%lld",ans)
#define llanss() printf("%lld ",ans)
#define llansn() printf("%lld\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<v.size();++i)
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000000+7;
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const ll infl = 1e16;
const int maxn= 1000000+10;
const int maxm = 40000+10;
int in(int &ret)
{
char c;
int sgn ;
if(c=getchar(),c==EOF)return -1;
while(c!='-'&&(c<'0'||c>'9'))c=getchar();
sgn = (c=='-')?-1:1;
ret = (c=='-')?0:(c-'0');
while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
ret *=sgn;
return 1;
}
char s[maxn];
int rightt[maxn];
int pos[30];
bool vis[30];
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif // LOCAL
int n,k;
sdd(n,k);
ss(s+1);
for(int i=n;i>=1;--i)
{
int idx = s[i]-'A';
rightt[i] = pos[idx];
pos[idx] = i;
}
int now = 0;
int ans = 0;
for(int i=1;i<=n;++i)
{
int idx= s[i]-'A';
if(rightt[i]&&!vis[idx])
{
vis[idx]=1;
now++;
if(now>ans)ans=now;
}
else if(!rightt[i])
{
if(!vis[idx])
{
ans = max(ans,now+1);
}
else
{
now--;
}
}
}
if(ans>k)puts("YES");
else puts("NO");
return 0;
}
C
每次操作对a b 总共乘3次
显然结果的a*b可以开出整数立方根
而对于每次操作的数 a b都至少被乘一次
所以一定能整除这个立方根
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
using namespace std;
#define pb push_back
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sddd(n,m,k) scanf("%d%d%d",&n,&m,&k)
#define slld(n) scanf("%lld",&n)
#define slldd(n,m) scanf("%lld%lld",&n,&m)
#define sllddd(n,m,k) scanf("%lld%lld%lld",&n,&m,&k)
#define slf(n) scanf("%lf",&n)
#define slff(n,m) scanf("%lf%lf",&n,&m)
#define slfff(n,m,k) scanf("%lf%lf%lf",&n,&m,&k)
#define ss(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define llans() printf("%lld",ans)
#define llanss() printf("%lld ",ans)
#define llansn() printf("%lld\n",ans)
#define r0(i,n) for(int i=0;i<(n);++i)
#define r1(i,e) for(int i=1;i<=e;++i)
#define rn(i,e) for(int i=e;i>=1;--i)
#define rsz(i,v) for(int i=0;i<v.size();++i)
#define mst(abc,bca) memset(abc,bca,sizeof abc)
#define lowbit(a) (a&(-a))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pli pair<ll,int>
#define mp make_pair
#define lrt rt<<1
#define rrt rt<<1|1
#define X first
#define Y second
#define PI (acos(-1.0))
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000000+7;
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const ll infl = 1e16;
const int maxn= 1000000+10;
const int maxm = 40000+10;
int in(ll &ret)
{
char c;
int sgn ;
if(c=getchar(),c==EOF)return -1;
while(c!='-'&&(c<'0'||c>'9'))c=getchar();
sgn = (c=='-')?-1:1;
ret = (c=='-')?0:(c-'0');
while(c=getchar(),c>='0'&&c<='9')ret = ret*10+(c-'0');
ret *=sgn;
return 1;
}
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif // LOCAL
int n;
sd(n);
for(int i=1;i<=n;++i)
{
ll a,b;
// slldd(a,b);
in(a),in(b);
ll pro = a*b;
ll l=1, r= 1000000;
bool ok=0;
ll ans = 0;
while(l<=r)
{
ll mid = (l+r)>>1;
if(mid*mid*mid==pro)
{
ans = mid;
ok=1;
break;
}
else if(mid*mid*mid>pro)r=mid-1;
else l=mid+1;
}
if(ans&&b%ans)ok=0;
if(ans&&a%ans)ok=0;
puts(ok?"Yes":"No");
}
return 0;
}