Question A:
Title Address: Currency System in Geraldion
Test instructions: Gives the face value of the currency in N (countless sheets per currency), which requires a minimum of the currency that cannot be expressed, if all denominations are represented, output-1.
Idea: Water problem, is to see if there is no face value of 1 of the currency, if any, all denominations of the currency can be obtained by 1 of the cumulative, if not, the smallest can not be expressed is of course 1 spicy.
#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;}
Question B:
Title Address: Gerald is into Art
Test instructions: There is a board and two pictures, asked whether the combination of two pictures can be in the board (two pictures can not overlap, can be Together)
Train of thought: altogether on 8 kinds of combination of way, are listed to be good.
#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;}
Question C:
Title address: Gerald ' s Hexagon
Test instructions: The given six-side clockwise hexagon can form a number of equilateral triangle with an area of 1.
Idea: In fact, is to seek the area of the hexagon, is a regular problem, find three unconnected side and then extend the formation of a large equilateral triangle and then subtract the extra fill of the small triangle is the final result.
#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", &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;}
Question d:
Title Address: Equivalent Strings
Test instructions: Give two equal-length strings, and then give a way to judge the equality of strings (two strings are cut into equal length two parts, a1,a2 and b1,b2, if A1=B1&&A2=B2 or A1=B2&&A2=B1), Lets you determine whether two strings are equal.
Idea: strings can be divided only by an even number of times, when only an odd number of times to compare from the back. Then search for a search.
#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, A, b)) {int Len=strlen (a); if (Find (A,b,len)) puts ("YES"); Else puts ("NO"); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Codeforces Round #313 (Div. 2) (A,B,C,D)