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;
}
浙公网安备 33010602011771号