Codeforces Round #282 (Div. 2)

Source: Internet
Author: User

Also hundreds of years did not do CF, this game is still done after the game, a lot of degradation

A.digital Counter

There may be a match stick lost, ask you how many of the number of possible numbers, only the naked eye to see each number of the match stick may form a number, a table on the line

#include <iostream>#include<cstdio>using namespacestd;Const intPos[] = {2,7,2,3,3,4,2,5,1,2};intA, B;intMain () {#ifdef LOCAL freopen ("495a.in","R", stdin);#endifa= GetChar ()-'0'; b= GetChar ()-'0'; printf ("%d\n", pos[a]*Pos[b]); return 0;}

B. Modular equations

At first did not read test instructions, thought is the same yu ... It is

a/x = y ... b gives you a A, a, a, you can ask for the number of X

Because B is the remainder, it needs to meet 0<=b<x

And the vegetarian number only needs to be checked to sqrt (x) almost, here only to enumerate to sqrt (A-B)

This complexity is still acceptable O (sqrt (A-B))

At first it was silly to enumerate from sqrt (A-B) to A-B ... Instant explosion ... TLE

#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>using namespacestd;Const intMAXN =1e5;intA, B, CNT;intPCNT[MAXN];BOOLPRIME[MAXN];intMain () {#ifdef LOCAL freopen ("495b.in","R", stdin);#endifscanf ("%d%d", &a, &b); if(A < b) printf ("0\n"); Else if(A = = b) printf ("infinity\n"); Else{a-=b;  for(inti =1, t = sqrt (a); I <= t; i++) {            if(A% i)Continue; intx = i, y = A/i; if(x > B) cnt++; if(Y > B) cnt++; if(x > b && x = = y) cnt--; } printf ("%d\n", CNT); }    return 0;}

C. Treasure

The feeling is greedy ... At the beginning of the idea of a silly, but also to subdivide a lot of discussion, and put themselves in the

is to let the front ' # ' fill in 1 ') ', and the last one to fill in the remaining required ') '

Run and check if there's a place that's going to make ' the number redundant ' (' number

#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <queue  >using namespace Std;const int maxn = 1e5+10;int mcnt, acnt, Hpos, Lpos, lh;intinf[maxn];char ins[maxn];bool possible = True;queue<int> h;void Noanswer () {printf (" -1\n"); exit (0);} int main () {#ifdef localfreopen ("495c.in", "R", stdin), #endifscanf ("%s", ins), for (int i = 0, t = strlen (ins); i < T; i++ {if (ins[i] = = ' (') mcnt++;else if (ins[i] = = ') ') mcnt--;else {lh = i;mcnt--;inf[i] = 1;h.push (i);}} if (mcnt < 0) noanswer () INF[LH] + = MCNT;MCNT = 0;for (int i = 0, t = strlen (ins); i < T; i++) {if (ins[i] = = ' (') mcnt++ ; else if (ins[i] = = ') ') mcnt--;else mcnt-= inf[i];if (mcnt < 0) noanswer ();} while (!h.empty ()) {printf ("%d\n", Inf[h.front ()]); H.pop ();} return 0;}

 

D.obsessive String

I feel that the D problem of CF is enough to sanction me ... KMP long forgotten, not to mention the DP, you have time to write it ~

ABC to feel the details are still quite a lot of, do not know because they degenerate, or the game partial details

Codeforces Round #282 (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.