SRM 471 Div 2 1000 points

Source: Internet
Author: User

TC does less, and all are always mixed in Div 2. -_-B

The whole process of srm471 is a tragedy.

First, compile and submit the gray card.

After that, the question writing in 500 points won't be compiled at all. Of course, it cannot be submitted.

Later, TC simply rushed everyone to the chat room.

However, somehow, rating can still rise.

 

The question of 250 points is very simple, but it is simply divided by the X power of 2 within a limited range. The number is the number of prime numbers.

To determine the prime number, you can directly use it to check whether the number is less than square. Most of the time, TC attacks are king.

 

500 points to view the number of eligible playlists.

Simple DP;

In addition, DP [I] [J] indicates the number of songs whose I position is J when the playback length is I;

DP [I] [J] = sum {DP [I-1] [k]}, where k indicates that the J-th song can be followed by the k-th song.

 

A question with 1000 points. This was not done at the time. However, the model is quite classic.

Is to give some paths, find the shortest path from 0 to the N-1 point, this shortest path is not a multiple of 13;

Maximum short circuit + dp;

In addition, DP [I] [J]: the minimum value of MOD 13 for the path from the 1st point to the jth point is I.

The rest is to find the shortest path and perform the relaxation operation.

# Include <iostream> <br/> # include <cstring> <br/> # include <algorithm> <br/> # include <string> <br/> # include <Map> <br/> # include <cmath> <br/> # include <set> <br/> # include <vector> <br/> using namespace STD; </P> <p> class thirteen <br/>{< br/> Public: <br/> int calctime (vector <string> City); <br/> }; </P> <p> int G [100] [100]; <br/> int GS (char ch) <br/>{< br/> If (CH = '#') Return-1; <br/> If (CH> = 'A ') return ch-'A' + 27; <Br/> return ch-'A' + 1; <br/>}</P> <p> int thirteen: calctime (vector <string> City) <br/> {<br/> int I, j, L = city. size (); <br/> for (I = 0; I <L; I ++) <br/> {<br/> for (j = 0; j <L; j ++) g [I + 1] [J + 1] = GS (City [I] [J]); <br/>}</P> <p> int DP [15] [1, 100]; <br/> memset (DP,-1, sizeof (DP )); </P> <p> set <pair <int, int> my; <br/> my. insert (make_pair (0, 1); <br/> while (! My. empty () <br/>{< br/> pair <int, int> PP = * My. begin (); <br/> my. erase (PP); <br/> int TT = pp. second; <br/> int val = pp. first; <br/> If (TT = L) return val; </P> <p> for (I = 1; I <= L; I ++) <br/> {<br/> If (G [TT] [I] =-1) continue; <br/> int W = G [TT] [I]; <br/> int now = W + val; <br/> If (now % 13 = 0) continue; <br/> int mod = now % 13; <br/> If (now <DP [mod] [I] | DP [mod] [I] =-1) <br/>{< br/> DP [mod] [I] = now; <br/> my. insert (make_pair (now, I); <br/>}< br/> return-1; <br/>}

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.