BZOJ2793: [Poi2012]vouchers

Source: Internet
Author: User

Exercises

The feeling is not to do the problem ah ...

See the puzzle to find violence can be too embarrassing ... Record how many x multiples were last taken.

Complexity: N/1+N/2+......+N/N=NLNN

Code:

1#include <cstdio>2#include <cstdlib>3#include <cmath>4#include <cstring>5#include <algorithm>6#include <iostream>7#include <vector>8#include <map>9#include <Set>Ten#include <queue> One#include <string> A #defineINF 1000000000 - #defineMAXN 1000000+5 - #defineMAXM 1000000+5 the #defineEPS 1e-10 - #definell Long Long - #definePA pair<int,int> - #defineFor0 (i,n) for (int i=0;i<= (n); i++) + #defineFor1 (i,n) for (int i=1;i<= (n); i++) - #defineFor2 (i,x,y) for (int i= (x); i<= (y); i++) + #defineFor3 (i,x,y) for (int i= (x); i>= (y); i--) A #defineFor4 (i,x) for (int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go) at #defineMoD 1000000007 - using namespacestd; -InlineintRead () - { -     intx=0, f=1;CharCh=GetChar (); -      while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();} in      while(ch>='0'&&ch<='9') {x=Ten*x+ch-'0'; ch=GetChar ();} -     returnx*F; to } + BOOLA[MAXN]; - intN,MX,NOW[MAXN]; the ll CNT,ANS[MAXN]; * BOOLV[MAXN]; $ intMain ()Panax Notoginseng { -Freopen ("Input.txt","R", stdin); theFreopen ("output.txt","W", stdout); +N=read ();intx; A      while(n--) A[x=read ()]=1, mx=Max (mx,x); then=read (); +      while(n--) -     { $X=read ();inty=x; $          for(inti=now[x]+x,j=0; i<=mx&&j<x;i+=x) -         { -             if(!V[i]) the             { -cnt++;y--;j++;Wuyiv[i]=1; the                 if(A[i]) ans[++ans[0]]=CNT; -             } Wunow[x]=i; -         } Aboutcnt+=y; $     } -printf"%lld\n", ans[0]); -For1 (i,ans[0]) printf ("%lld\n", Ans[i]); -     return 0; A}
View Code

BZOJ2793: [Poi2012]vouchers

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.