Codeforces Round #426 (Div. 2)

 

A,判断向哪边旋转的,枚举过的=  =,感觉我的太复杂了,应该有更简单的方法

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-7;
const int N=200000+10,maxn=500+100,inf=0x3f3f3f;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a,b;
    int n;
    cin>>a>>b>>n;
    n%=4;
    if(a[0]=='^')
    {
        if(b[0]=='>')
        {
            if(n==1)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==3)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
        if(b[0]=='v')
        {
            if(n==2)
            {
                cout<<"undefined"<<endl;
                return 0;
            }
        }
        if(b[0]=='<')
        {
            if(n==3)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==1)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
    }
   if(a[0]=='>')
    {
        if(b[0]=='v')
        {
            if(n==1)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==3)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
        if(b[0]=='<')
        {
            if(n==2)
            {
                cout<<"undefined"<<endl;
                return 0;
            }
        }
        if(b[0]=='^')
        {
            if(n==3)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==1)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
    }
    if(a[0]=='v')
    {
        if(b[0]=='<')
        {
            if(n==1)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==3)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
        if(b[0]=='^')
        {
            if(n==2)
            {
                cout<<"undefined"<<endl;
                return 0;
            }
        }
        if(b[0]=='>')
        {
            if(n==3)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==1)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
    }
    if(a[0]=='<')
    {
        if(b[0]=='^')
        {
            if(n==1)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==3)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
        if(b[0]=='>')
        {
            if(n==2)
            {
                cout<<"undefined"<<endl;
                return 0;
            }
        }
        if(b[0]=='v')
        {
            if(n==3)
            {
                cout<<"cw"<<endl;
                return 0;
            }
            else if(n==1)
            {
                cout<<"ccw"<<endl;
                return 0;
            }
        }
    }
    cout<<"undefined"<<endl;
    return 0;
}
/********************

********************/
A

B,判断同时打开的门最大有多少,暴力艹过了(yes,no写反,导致wa了一发)

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-7;
const int N=200000+10,maxn=500+100,inf=0x3f3f3f;

int b[30],e[30];
set<int>ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    string s;
    cin>>n>>k>>s;
    memset(b,-1,sizeof b);
    memset(e,-1,sizeof e);
    for(int i=0;i<n;i++)
    {
        int p=s[i]-'A';
        if(b[p]==-1)b[p]=e[p]=i;
        else e[p]=i;
    }
    int res=0;
    for(int i=0;i<n;i++)
    {
        int p=s[i]-'A';
        if(i==b[p])ans.insert(p);
        res=max(res,(int)ans.size());
        if(i==e[p])ans.erase(p);
    }
    //cout<<res<<endl;
    if(res<=k)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}
/********************

********************/
View Code

C,先判断a*b是不是某个数(k)的3次方,再根据a/k,b/k相乘是不是等于k判断,这里要除k的原因是有可能a,b中其中一个是含有k因子的3次方,这样除k之后就是小于0了(wa了四发才过)

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-7;
const int N=200000+10,maxn=500+100,inf=0x3f3f3f;

map<ll,ll>ma;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
   /* ios::sync_with_stdio(false);
    cin.tie(0);*/
    for(ll i=1;i<=1e6;i++)
    {
        ll p=i*i*i;
        ma[p]=i;
    }
    ll n;
    scanf("%lld",&n);
    while(n--){
        ll a,b;
        scanf("%lld%lld",&a,&b);
        ll p=ma[a*b];
        if(p!=0)
        {
            ll aa=a/p,bb=b/p;
            if(aa*bb==p)printf("Yes\n");
            else printf("No\n");
        }
        else printf("No\n");
    }
    return 0;
}
/********************

********************/
View Code

 

posted @ 2017-07-31 11:48  walfy  阅读(130)  评论(0编辑  收藏  举报