Lyft Level 5 Challenge 2018-elimination round Rollover

Source: Internet
Author: User
Tags cmath

The sudden death field feels very dead.

A: Judge whether the starting and ending points are on either side.

#include <iostream>#include<cstdio>#include<cmath>#include<cstdlib>#include<cstring>#include<algorithm>using namespacestd;intRead () {intx=0, f=1;CharC=GetChar ();  while(c<'0'|| C>'9') {if(c=='-') f=-1; c=GetChar ();}  while(c>='0'&&c<='9') x= (x<<1) + (x<<3) + (c^ -), c=GetChar (); returnx*F;}#defineNintN,ax,ay,bx,by,cx,cy;intMain () {n=read (), Ax=read (), Ay=read (), Bx=read (), By=read (), Cx=read (), cy=read (); if(bx<ax&&cx>ax| | bx>ax&&cx<ax| | by<ay&&cy>ay| | By>ay&&cy<ay) cout<<"NO"; Elsecout<<"YES"; return 0;}
View Code

B: The formula for the squared difference, when and only if A-b=1 and A+b is prime, A2-B2 is prime.

#include <iostream>#include<cstdio>#include<cmath>#include<cstdlib>#include<cstring>#include<algorithm>using namespacestd;intRead () {intx=0, f=1;CharC=GetChar ();  while(c<'0'|| C>'9') {if(c=='-') f=-1; c=GetChar ();}  while(c>='0'&&c<='9') x= (x<<1) + (x<<3) + (c^ -), c=GetChar (); returnx*F;}#definell Long Longintt;ll n,m;intMain () {T=read ();  while(t--) {cin>>n>>m; ll a=n+m,b=n-m; if(b>1) {cout<<"no\n";Continue;} BOOLflag=1;  for(LL i=2; i*i<=a;i++)        if(a%i==0) {flag=0; Break;} if(flag) cout<<"yes\n"; Elsecout<<"no\n"; }    return 0;}
View Code

C: If the successor State is a winning state, then the state will be defeated, otherwise the winning state. Can be updated by number from large to minor violence, the complexity of the harmonic series is guaranteed.

#include <iostream>#include<cstdio>#include<cmath>#include<cstdlib>#include<cstring>#include<algorithm>using namespacestd;intRead () {intx=0, f=1;CharC=GetChar ();  while(c<'0'|| C>'9') {if(c=='-') f=-1; c=GetChar ();}  while(c>='0'&&c<='9') x= (x<<1) + (x<<3) + (c^ -), c=GetChar (); returnx*F;}#defineN 100010intN,a[n],id[n],flag[n];intMain () {n=read ();  for(intI=1; i<=n;i++) Id[a[i]=read ()]=i; memset (Flag,255,sizeof(flag)); Flag[id[n]]=0;  for(inti=n-1; i>=1; i--)     {        intx=Id[i];  for(intj=x-i;j>=1; j-=i)if(A[j]>i&&!flag[j]) {flag[x]=1; Break;} if(flag[x]==-1)         for(intj=x+i;j<=n;j+=i)if(A[j]>i&&!flag[j]) {flag[x]=1; Break;} if(flag[x]==-1) flag[x]=0; }     for(intI=1; i<=n;i++)if(Flag[i]) printf ("A");Elseprintf"B"); return 0;}
View Code

D: The number of factors is only in these cases between the three species: Pq,p2,p3,p4. The power of P can be calculated directly, preserving all the obtained prime numbers. The PQ is then considered, and the number is removed from the gcd of all the prime numbers that appeared before, leaving the new quality factor. began to make a direct delivery of the pungent meat of the unexpected T dropped. Then maybe because it is too late, the brain is not awake, in a strange way to start the code positive solution, and five times after the last FST dropped.

E, F, G: How could it be?

result:rank437 rating+7

Lyft Level 5 Challenge 2018-elimination round Rollover

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.