51nod Algorithm Marathon 28-a

Source: Internet
Author: User

A piece of water:

According to greedy thought to find is 2 of the K-square, and then high-precision calculation


#include <bits/stdc++.h>using namespacestd;Const intn=10005;intAns,n,a[n],b[n];structzz{intLen,a[n]; voidinit () {memset (A,0,sizeofa); Len=0; }    voidWrite () { for(inti=len;i;i--) printf ("%d", A[i]);} ZZoperator*(ConstZZ B)         {zz H;h.init (); H.len=len+b.len-1;  for(intI=1; i<=len;i++)           for(intj=1; j<=b.len;j++) H.a[i+j-1]+=a[i]*B.a[j], h.a[i+j]+=h.a[i+j-1]/Ten, h.a[i+j-1]%=Ten; if(H.a[len+b.len]) h.len++; returnh; }}x,y;voidKsmintk) {x.a[1]=x.len=y.len=1; y.a[1]=2;  while(k) {if(k%2==1) x=x*y; Y=y*y; K/=2; }}intMain () {scanf ("%d",&N);  for(intI=0; i<n;i++) scanf ("%d",&A[i]);  for(intI=0; i<n;i++) scanf ("%d",&B[i]);  for(intI=1; i<n;i++)      for(intj=0; j<n;j++)      if(a[i]==b[j]&&a[i-1]==b[j+1]) ans++;    KSM (ANS);    X.write (); return 0;}

51nod Algorithm Marathon 28-a

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.