Codeforces Round #313 (Div. 2)(A,B,C,D)

A题:

题目地址:Currency System in Geraldion

题意:给出n中货币的面值(每种货币有无数张),要求不能表示出的货币的最小值,若所有面值的都能表示,输出-1.

思路:水题,就是看看有没有面值为1的货币,如果有的话,所有面值的货币都可以通过1的累加得到,如果没有的话,最小的不能表示的就当然是1辣。

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-6;
int main()
{
    int n,m,i;
    while(~scanf("%d",&n))
    {
        int flag = 0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&m);
            if(m == 1)
                flag = 1;
        }
        if(flag == 1)
            printf("-1\n");
        else
            printf("1\n");
    }
    return 0;
}

B题:

题目地址:Gerald is into Art

题意:有一块板子和两幅画,问两幅画的组合是不是可以在板子内(两幅画不可以重合相交,可以边在一起)

思路:一共就8种组合的方式,都列出来就好了。

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-6;
int main()
{
    int n,m,a,b,c,d;
    int flag;
    while(~scanf("%d %d",&n,&m)){
        scanf("%d %d",&a,&b);
        scanf("%d %d",&c,&d);
        flag=0;
        if(a+c<=n&&max(b,d)<=m){
           flag=1;
        }
        else if(a+c<=m&&max(b,d)<=n){
            flag=1;
        }
        else if(a+d<=n&&max(b,c)<=m){
            flag=1;
        }
        else if(a+d<=m&&max(b,c)<=n){
            flag=1;
        }
        else if(b+d<=n&&max(a,c)<=m){
            flag=1;
        }
        else if(b+d<=m&&max(a,c)<=n){
            flag=1;
        }
        else if(b+c<=n&&max(a,d)<=m){
            flag=1;
        }
        else if(b+c<=m&&max(a,d)<=n){
            flag=1;
        }
        if(flag)
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}

C题:

题目地址:Gerald‘s Hexagon

题意:给出的六条边顺时针组成的六边形能形成多少个面积为1的等边三角形。

思路:其实就是求该个六边形的面积,算是个规律题,找三条不相连的边然后延长形成一个大的等边三角形然后减去多余的填充的小三角形就是最后的结果。

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-6;
int main()
{
    int a,b,c,d,e,f;
    int t,ans;
    while(~scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)){
        t=(e+d+c);
        ans=t*t-a*a-e*e-c*c;
        printf("%d\n",ans);
    }
    return 0;
}

D题:

题目地址:Equivalent Strings

题意:给出两个等长的字符串,然后给出一个判断字符串相等的方法(将两个字符串分别切成等长的两部分,a1,a2和b1,b2,如果a1=b1&&a2=b2或者a1=b2&&a2=b1),让判断两个字符串是否相等。

思路:字符串只有偶数个的时候才可以划分,当只有奇数个的时候就从头向后比较。然后搜一搜就好了。

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long LL;
const int inf=0x3f3f3f3f;
const double pi= acos(-1.0);
const double esp=1e-6;
const int MAXN=200010;
char a[MAXN],b[MAXN];
int Find(char *str1,char *str2,int len)
{
    int i;
    if(len&1){
        for(i=0;i<len;i++){
            if(str1[i]!=str2[i])
                return 0;
        }
        return 1;
    }
    int n=len/2;
    if(Find(str1,str2+n,n)&&Find(str1+n,str2,n))
        return 1;
    if(Find(str1,str2,n)&&Find(str1+n,str2+n,n))
        return 1;
    return 0;
}
int main()
{
    while(~scanf("%s %s",a,b)){
        int Len=strlen(a);
        if(Find(a,b,Len))
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-11-07 21:38:41

Codeforces Round #313 (Div. 2)(A,B,C,D)的相关文章

Codeforces Round #313 (Div. 2) Gerald&#39;s Hexagon

给出一个六边形六条边的长度(六边形的每个角为120度),求出这个六边形中边长为1的等边三角形有多少个 由于每个角都是120度并且上下两条边是平行的,因此我们可以补出一个矩形,再减掉周边四个角的面积,用剩下面积除以每个小三角形的面积. #include<cstdio> using namespace std; double a,b,c,d,e,f; int main() { <span style="white-space:pre"> </span>s

Codeforces Round #313 (Div. 2) C Gerald&#39;s Hexagon 计数

// Codeforces Round #313 (Div. 2) C Gerald's Hexagon // 计数 // 关键是平行于a1的长度为1的有多少条,中间的这些*2,再加上a1 // 和a4,就是三角形的总和 // 还是挺简单的,注意递增的初始值,和变化,就ac了 #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> using namespac

Codeforces Round #313 (Div. 1)

官方英文题解:http://codeforces.com/blog/entry/19237 Problem A: 题目大意: 给出内角和均为120°的六边形的六条边长(均为正整数),求最多能划分成多少个边长为1的正三角形. 题解: 把六边形补全变成一个正三角形,然后减去三个角的正三角形即可. Problem B: 题目大意: 给出长度相等的两个串AB,定义两个串相等 当且仅当  A=B  或者  当长度为偶数时,A[1...n/2]=B[1...n/2]  && A[n/2+1...n]=

【打CF,学算法——一星级】Codeforces Round #313 (Div. 2) A. Currency System in Geraldion

[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/A 题面: A. Currency System in Geraldion time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A magic island Geraldion, where Gerald lives,

Codeforces Round #313 (Div. 2) (ABCD题解)

比赛链接:http://codeforces.com/contest/560 水笔场... A. Currency System in Geraldion time limit per test:2 seconds memory limit per test:256 megabytes A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several va

Codeforces Round #313 (Div. 2)B.B. Gerald is into Art

B. Gerald is into Art Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/560/B Description Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought

【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)

[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Gerald bought two very rare paintings at the Sotheby's a

Codeforces Round #313 (Div. 2) C. Geralds Hexagon(补大三角.cpp

 Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters.

Codeforces Round #313 (Div. 2) C. Geralds Hexagon

Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. Th

Codeforces Round #313 (Div. 1) C. Gerald and Giant Chess

这场CF又掉分了... 这题题意大概就给一个h*w的棋盘,中间有一些黑格子不能走,问只能向右或者向下走的情况下,从左上到右下有多少种方案. 开个sum数组,sum[i]表示走到第i个黑点但是不经过其他黑点的方案数. 式子是sum[i]=c(x[i]+y[i],x[i])-Σ(sum[j]*c(x[i]-x[j]+y[i]-y[j],x[i]-x[j])). c(x+y,x)表示从格子(1,1)到(x,y)的方案数(没有黑点). 因此每个点按x[i]+y[i]的值排个序,然后n^2弄一下他们的拓扑