Codeforces Round #279 (Div. 2) 解题报告_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:53:25
Original
1050 people have browsed it

A - Team Olympiad

贪心水题。。都从第一个开始取即可。

代码如下:

#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64int a[6000], b[6000];int main(){    int n, x, y, z, ans, i, j;    while(scanf("%d",&n)!=EOF)    {        x=y=z=0;        for(i=0;i<n scanf memset for if x b else y z ans="min(x,min(y,z));" printf puts return>  <br>  B - Queue  <br>  <p></p>  <p>通过用数组记录下一个位置,分别把偶数位置与奇数位置上的填满。</p>  <p>偶数位置上一定是从0开始的,奇数位置一定是从一个没有出度只有入度的一个数开始的。</p>  <p>代码如下:</p>  <p></p>  <pre name="code" class="sycode">#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64int next[1100000], a[1100000], out[1100000];struct node{    int u, v;}fei[1100000];int main(){    int n, i, j, u, v, cnt, pos;    while(scanf("%d",&n)!=EOF)    {        memset(next,-1,sizeof(next));        memset(out,0,sizeof(out));        for(i=0;i<n scanf next out cnt="1;" for if break a pos="fei[i].u;" printf return>  <br>  C - Hacking Cypher  <br>  <p></p>  <p>分别从前和后扫一遍记录下能整除的位置。从前往后的很好处理。</p>  <p>至于从后往前的,对于第k位来说,可以先预处理10^k对b的余数和以及前k位对b的余数,然后,后几位=总数-前k位表示的数*10^k。所以只要满足总数%b==(前k位表示的数%b)*(10^k%b)%b,就标明后几位表示的数可以整除b。</p>  <p>这样就可以在O(n)的复杂度内完成了。</p>  <p>表示自己真是弱渣。。看别人都一会儿就做出来了。。自己却想了半个小时才想出来。。。</p>  <p>代码如下:</p>  <p></p>  <pre name="code" class="sycode">#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64int a[1100000], b[1100000], c[1100000], d[1100000];char s[1100000];int main(){    int aa, bb, i, x, len, pos, flag=0, y;    gets(s);    scanf("%d%d",&aa,&bb);    memset(a,0,sizeof(a));    memset(d,0,sizeof(d));    x=1;    c[1]=1%bb;    for(i=2;i  <br>  D - Chocolate  <br>  <p></p>  <p>如果最终的面积相等的话,那么2的因子数与3的因子数一定相等。所以可以先求出2的因子数与3的因子数。然后这时候我们可以有两种操作:消去一个2或者把一个3变成2.所以这时候先把3较大的一方变成2,使得剩下的3相等,然后再消去2的因子数较大的一方使得相等。然后在判断这时候双方面积相等即可。</p>  <p>代码如下:</p>  <p></p>  <pre name="code" class="sycode">#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64int main(){    int a1, b1, a2, b2, x2, x3, y2, y3, ans, m1, m2, n1, n2;    while(scanf("%d%d%d%d",&a1,&b1,&a2,&b2)!=EOF)    {        m1=a1;        m2=a2;        n1=b1;        n2=b2;        x2=x3=y2=y3=0;        while(!(a1%2)||!(a1%3))        {            if(a1%2==0)            {                x2++;                a1/=2;            }            if(a1%3==0)            {                x3++;                a1/=3;            }        }        while(!(b1%2)||!(b1%3))        {            if(b1%2==0)            {                x2++;                b1/=2;            }            if(b1%3==0)            {                x3++;                b1/=3;            }        }        while(!(a2%2)||!(a2%3))        {            if(a2%2==0)            {                y2++;                a2/=2;            }            if(a2%3==0)            {                y3++;                a2/=3;            }        }        while(!(b2%2)||!(b2%3))        {            if(b2%2==0)            {                y2++;                b2/=2;            }            if(b2%3==0)            {                y3++;                b2/=3;            }        }        if(x3>=y3)        {            x2+=x3-y3;            ans=x3-y3;            for(int i=0; i<x3-y3 i if m1="m1/3*2;" else n1="n1/3*2;" y2 ans="y3-x3;" for m2="m2/3*2;" n2="n2/3*2;">=y2)        {            for(int i=0; i<x2-y2 i if m1 else n1 for m2 n2 puts printf return>  <br>  <br>  <p></p> </x2-y2></x3-y3></algorithm></set></map></queue></ctype.h></math.h></stdlib.h></cstring></string></cstdio></iostream>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!