zoukankan      html  css  js  c++  java
  • Codeforces Round #313 (Div. 2) A.B,C,D,E Currency System in Geraldion Gerald is into Art Gerald's Hexagon Equivalent Strings

    A题,超级大水题,根据有没有1输出-1和1就行了。我沙茶,把%d写成了%n。

    B题,也水,两个矩形的长和宽分别加一下,剩下的两个取大的那个,看看是否框得下。

    C题,其实也很简单,题目保证了小三角形是正三角形,一个正三角的面积=l*l*(1/2)*cos(30),由于只要算三角形个数,把六边形扩成一个大三角,剪掉三个小三角,除一下系数就没了。就变成了平方相减。

    D题,根据定义递归。然后注意奇数就行了。我沙茶,没加第一种判断dfs(a+len,len,b+len) && dfs(a,len,b)。

    E题,有思路,没写代码,就是个DP,设当前走到r,c且不经过黑点的方案数为dp[r][c],转移的时候用C(r+c-2,r-1)可以算出从(0,0)点走到(r,c)的方案数,然后减去从之前的黑点走到(r,c)的方案数。

    总结,好好读题,仔细敲代码

    A题

    #define HDU
    #ifndef HDU
    #include<bits/stdc++.h>
    #else
    #include<cstdio>
    #include<cmath>
    #include<vector>
    #include<map>
    #include<set>
    #include<algorithm>
    #include<cstring>
    #endif // HDU
    using namespace std;
    //const int maxn = 1009;
    //int n;
    //int a[maxn];
    int main()
    {
    #ifdef local
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif // local
        int t;
        int n;
        while(~scanf("%d",&n)){
            bool flag = 0;
            for(int i = 0; i < n; i++){
                scanf("%d",&t);
                if(t == 1) flag = 1;
    
            }
            if(flag) printf("-1");
            else printf("1");
        }
        return 0;
    }
    
    /*
      // for(int i = 0; i < n; i++){
        //}
    
      scanf("%d",a+i);
        sort(a,a+n);
        if(a[0] == 1 ){
    
        }else
    */
    View Code

    B题

    #define HDU
    #ifndef HDU
    #include<bits/stdc++.h>
    #else
    #include<cstdio>
    #include<cmath>
    #include<vector>
    #include<map>
    #include<set>
    #include<algorithm>
    //#include<iostream>
    #endif // HDU
    using namespace std;
    
    //#define local
    #define PY { puts("YES"); return 0; }
    #define PN { puts("NO"); return 0; }
    
    int main()
    {
    #ifdef local
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif // local
        int a0,b0;
        scanf("%d%d",&a0,&b0);
        int a1,b1,a2,b2;
        scanf("%d%d%d%d",&a1,&b1,&a2,&b2);
        int t = (a1+a2),t2 = max(b1,b2);
        if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
        t = (a1+b2); t2 = max(b1,a2);
        if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
        t = (b1+a2); t2 = max(a1,b2);
        if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
        t = (b1+b2); t2 = max(a1,a2);
        if((t<=a0 && t2<= b0)|| (t<=b0 && t2<=a0) ) PY;
        PN;
        return 0;
    }
    View Code

    C题

    #define HDU
    #ifndef HDU
    #include<bits/stdc++.h>
    #else
    #include<cstdio>
    #include<cmath>
    #include<vector>
    #include<map>
    #include<set>
    #include<algorithm>
    //#include<iostream>
    #endif // HDU
    using namespace std;
    
    //#define local
    
    int main()
    {
    #ifdef local
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif // local
        int a,b,c,d,e,f,g;
        scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g);
        int l = a+b+c;
        int ans = l*l - a*a - c*c - e*e;
        printf("%d",ans);
        return 0;
    }
    View Code

    D题

    #define HDU
    #ifndef HDU
    #include<bits/stdc++.h>
    #else
    #include<cstdio>
    #include<cmath>
    #include<vector>
    #include<map>
    #include<set>
    #include<algorithm>
    #include<cstring>
    #endif // HDU
    using namespace std;
    
    //#define local
    
    bool dfs(char *a,int len,char *b)
    {
        if(len == 1) { return (*a) == (*b); }
        if(memcmp(a,b,len) == 0) return true;
        if(len&1) return false;
        len >>= 1;
        return (dfs(a,len,b+len) && dfs(a+len,len,b))||(dfs(a+len,len,b+len) && dfs(a,len,b));
    }
    
    const int maxn = 200000+5;
    char a[maxn],b[maxn];
    
    int main()
    {
    #ifdef local
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif // local
        scanf("%s%s",a,b);
        int len = strlen(a);
        printf("%s
    ",dfs(a,len,b)?"YES":"NO");
        return 0;
    }
    View Code
  • 相关阅读:
    win7-64系统下安装nodejs
    Vue项目使用npm run dev出现npm ERR! missing script: dev
    本地环境时覆盖Apollo配置
    金蝶K3序时簿页面增加物料即时库存显示功能
    LeetCode——开篇
    url 与 params 参数的常见操作归纳汇总(含精心准备的注释)
    如何让 arcgis require 里定义的方法可以在全局访问?
    字体图标库 iconfont、iconmoon 的维护管理与使用探索
    【转载】ES5-ES12 常用语法特性
    一次 outline 去除经验(非继承属性,看着像继承)
  • 原文地址:https://www.cnblogs.com/jerryRey/p/4669862.html
Copyright © 2011-2022 走看看