Codeforces Round #313 (Div. 2)

Source: Internet
Author: User
Tags bitset cmath

Match Link Click here~~

Question A:

"Idea": if the input has 1 is-1, otherwise is 1.

Question B: give you three rectangular size, ask after two can be placed in the first rectangle, enumerate each case, there is a valid is yes, otherwise is no.

Code:

C#ifndef _glibcxx_no_assert#include <cassert> #endif # include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath># Include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio > #include <cstdlib> #include <cstring> #include <ctime>//C + + #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream># Include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream > #include <istream> #include <iterator> #include <limits> #include <list> #include < locale> #include <map> #include <memory> #include <new> #include <numeric> #include < ostream> #include <queue> #include <set> #include <sstream> #include <stack> #inClude <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include < utility> #include <valarray> #include <vector>using namespace std; #define REP (i,j,k) for (int i= (int) j;i < (int) k;++i) #define PER (i,j,k) for (int i= (int) j;i> (int) k;--i) #define LOWBIT (a) A&-a#define Max (A, b) a>b? A:b#define Min (A, B) a>b?b:a#define mem (A, B) memset (A,b,sizeof (a)) typedef long Long ll;typedef unsigned long long llu;t Ypedef double db;const int n=1e5+100;const int inf=0x3f3f3f3f;int N,m,t,ans,res,cnt,tmp;char str[n];bool vis[N];int mat[ 1005][1005];///State before int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};int dir8[8][2]= {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-    1,-1},{0,-1},{1,-1}};int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}};inline LL read () {int c=0,f=1;    Char Ch=getchar (); while (ch< ' 0 ' | |        Ch> ' 9 ') {if (ch== '-') f=-1;    Ch=getchar ();        } while (ch>= ' 0 ' &&ch<= ' 9 ') {c=c*10+ch-' 0 '; Ch=getchar ();   } return c*f;} int A1,b1;int a2,b2;int a3,b3;bool get (int x,int y) {if (x<=a1&&y<=b1| |    Y&LT;=A1&AMP;&AMP;X&LT;=B1) return 1; return 0;}        int main () {while (CIN&GT;&GT;A1&GT;&GT;B1) {cin>>a2>>b2;        cin>>a3>>b3;        BOOL F1=get (A2+a3,max (B2,B3));        BOOL F2=get (B2+b3,max (A2,A3));        BOOL F3=get (A2+b3,max (B2,A3));        BOOL F4=get (A3+b2,max (A2,B3)); if (f1| | f2| | f3| |        F4) puts ("YES");    Else puts ("NO"); } return 0;} /*sample Test (s) input3 1outputyesinput5 3outputnoinput4 2outputyes100 1641 7624 15no*/

question c:

Give a hexagon with a 120-degree angle to each inner corner, and ask how many sides of the hexagon can be placed with a length of 1 equilateral triangle

"Thinking": math problem, you can divide the title of this hexagon into two isosceles trapezoid and the middle of a parallelogram, so you can calculate the number of triangles contained in each graph, and finally add the line.

Code:

C#ifndef _glibcxx_no_assert#include <cassert> #endif # include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath># Include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio > #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103l#include < ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool># Include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif//C + + #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception># Include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd > #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream># Include <stack> #include <stdexcept> #include <streambuf> #include <string> #include < typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103l# Include <array> #include <atomic> #include <chrono> #include <condition_variable> #include < forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random > #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error># Include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include < unordered_map> #include <unordered_set> #endifusing namespace std; #define REP (i,j,k) for (iNT i= (int) j;i< (int) k;++i) #define PER (i,j,k) for (int i= (int) j;i> (int) k;--i) #define LOWBIT (a) A&-a#define Max (A, B) a>b?a:b#define Min (A, B) a>b?b:a#define mem (A, B) memset (A,b,sizeof (a)) typedef long Long Ll;typedef unsigned Long long llu;typedef double db;const int n=1e5+100;const int inf=0x3f3f3f3f;int N,m,t,ans,res,cnt,tmp;char Str[N];bool v Is[n];int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};int dir8[8][2]= {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1}, {1,-1}};    int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}};inline LL read () {int c=0,f=1;    Char Ch=getchar (); while (ch< ' 0 ' | |        Ch> ' 9 ') {if (ch== '-') f=-1;    Ch=getchar ();        } while (ch>= ' 0 ' &&ch<= ' 9 ') {c=c*10+ch-' 0 ';    Ch=getchar (); } return c*f;} int uu[100];int Calc1 (int a,int h) {return (2*a*h+h*h);} int calc2 (int a,int h) {return 2*a*h;}    int main () {for (int i=0; i<6; ++i) {cin>>uu[i];    } int h1=uu[1]+uu[2]; int H2=min (uu[1],uU[5]);    int h3=min (uu[2],uu[4]);    Cout<<calc1 (UU[0],H2) +calc2 (UU[0]+H2,H1-H2-H3) +calc1 (UU[3],H3) <<endl; return 0;}

D: To satisfy the conditions of the string, two-length string, divided into the same two parts, if the two parts satisfy the condition, the string is equal, determine whether the equality

"Idea" if len&1, then directly judge, otherwise, search two strings remaining parts

Code:

B. Equivalent Strings#ifndef _glibcxx_no_assert#include <cassert> #endif # include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale># Include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef > #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime>//C + + #include < algorithm> #include <bitset> #include <complex> #include <deque> #include <exception># Include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd > #include <iostream> #include <istream> #include <iterator> #include <limits> #include < list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric > #include <ostream> #include <queue> #include <set> #include <sstream> #inClude <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo > #include <utility> #include <valarray> #include <vector>using namespace std; #define REP (I,j,k) for (int i= (int) j;i< (int.) k;++i) #define PER (i,j,k) for (int i= (int) j;i> (int) k;--i) #define LOWBIT (a) a&-a# Define MAX (A, B) a>b?a:b#define Min (A, B) a>b?b:a#define mem (A, B) memset (A,b,sizeof (a)) typedef long Long Ll;typedef Unsigned long long llu;typedef double db;const int n=2*1e5+100;const int inf=0x3f3f3f3f;int n,m,t,ans,res,cnt,tmp;int hh[ 28];char Str1[n],str2[n];bool Vis[n];int mat[1005][1005];int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};int dir8[8][2]= {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};int movv[5][2]= {{1,0},{0,1},{0,0},{-1,0},{0,-1}};inline    LL read () {int c=0,f=1;    Char Ch=getchar (); while (ch< ' 0 ' | |        Ch> ' 9 ') {if (ch== '-') f=-1;    Ch=getchar ();       } while (ch>= ' 0 ' &&ch<= ' 9 ') { c=c*10+ch-' 0 ';    Ch=getchar (); } return c*f;}    int A1,b1;int a2,b2;int a3,b3;bool dfs (char *s,char *t,int len) {if (len&1) return strncmp (S,t,len) ==0;    MEM (hh,0);        for (int i=0; i<len; ++i) {hh[s[i]-' a ']++;    hh[t[i]-' a ']--;    } for (int i=0; i<26; ++i) {if (hh[i]!=0) return false;    } len/=2;    if (Dfs (S,t,len) &&dfs (S+len,t+len,len)) return true;    if (Dfs (S+len,t,len) &&dfs (S,t+len,len)) return true; return false;}    int main () {scanf ("%s%s", STR1,STR2);    int Len=strlen (STR1); printf ("%s\n", DFS (Str1,str2,len)? "    YES ":" NO "); return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Codeforces Round #313 (Div. 2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.