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
  • 相关阅读:
    各类免费资料及书籍索引大全(珍藏版)
    转—如何写一篇好的技术博客
    如何写技术博客
    Spring + Spring MVC + Mybatis 框架整合
    Httpclient 4.5.2 请求http、https和proxy
    HttpClient4.5.2 连接池原理及注意事项
    php加密数字字符串,使用凯撒密码原理
    php 阿里云视频点播事件回调post获取不到参数
    Nginx代理后服务端使用remote_addr获取真实IP
    记录:mac的浏览器访问任何域名、网址都跳转到本地127.0.0.1或固定网址
  • 原文地址:https://www.cnblogs.com/jerryRey/p/4669862.html
Copyright © 2011-2022 走看看