The test race writing the puzzle will not be spit groove it ...
Knockout car
Time limit: 1000ms
Memory: 262144K
The racing race has become more and more popular in Pandora. But their game is not the same as our usual: N-Cars compete on a long straight track. The speed of each car is 1m/s, and the entire track is marked with coordinates at every metre.
In racing cars, the car I moved from AI to bi starting at 0 seconds. When you reach Bi, you move back to the AI by BI. Cycle.
Another garlic fungus! Originally this is the garlic fungus is playing a mobile phone game. Garlic fungus can put down TNT in some places to blow up some cars. Because he has a m problem. The question J is: how many cars are there between Xi and Yi at TJ moment?
Your task is to answer the question of Meng garlic.
Input
The first line of input contains two numbers n and M (1≤n, m≤1000), respectively, representing the number of racing cars and the number of garlic problems in the race.
In the next n rows, each line contains 2 integers ai, bi (0≤ai, bi≤109, ai! = bi), each representing the start and end of the racing I.
In the next M row, each row contains 3 integers xj,yj,tj (0≤xj≤yj≤109, 0≤tj≤109), representing the left and right coordinate boundaries of the question J and the time of the query.
Output
The output has a total of m rows, each with an integer representing the answer to the corresponding m question.
Example 1
Input:
5 50 10 22 33 54 50 5 00 1 20 2 12 5 22 5 3
Output:
51243
Topic Analysis: Actually is a big water problem ah, is mainly oneself too sb, at first did not analyze well, because the car is to open, M and N are 1e3, so the direct online solution, for each runway of the car to find the position of T moment, judge in not the target range, the method is each class to take the mold
#include <cstdio> #include <cstring>int const MAX = 1005;int A[max], B[max];int main () { int n, m; while (scanf ("%d%d", &n, &m)! = EOF) { for (int i = 0; i < n; i++) scanf ("%d%d", &a[i], &b[ I]); while (m--) { int x, y, T; scanf ("%d%d%d", &x, &y, &t); int ans = 0; for (int i = 0; i < n; i++) { int tmp, DIS = b[i]-a[i]; if ((t/dis)% 2 = = 0) tmp = A[i] + (t% dis); else tmp = b[i]-(t% dis); if (tmp <= y && tmp >= x) ans + +; } printf ("%d\n", ans);}}
Substitution of Jokes
Time limit: 1000ms
Memory: 262144K
the little garlic is naughty again. This time, my sister's experiment report was brutally poisoned.
My sister's experiment report originally recorded a sequence from 1 to N, with any two-digit space between them. But the "pit elder sister" of the garlic incredibly the space between the numbers are deleted, the entire number of the sequence into a length of 1 to 100, and the first no space number string.
Now the sister has been angry, garlic to find you write a program to quickly restore the experimental data.
Input
The input file has a line that is a string-the experimental data that was messed up by the garlic.
The length of the string is between 1 and 100.
Output
Output a total of one row for the sister's original test data--1 to n output.
There is a space between any of the two data.
Example 1
Input:
4111109876532
Output:
4 1 11 10 9 8 7 6 5 3 2
Title Analysis: First we can calculate the value of n by the length of the string, when Len <= 9 o'clock, N=len, otherwise n = 9 + (len-9)/2, and then DFS Search, all kinds of scissors, directly see the program bar
#include <cstdio> #include <cstring>char s[105];int num[100];int len, N;bool flag, Vis[100];bool OK ()// Determine if it is valid {bool Has[100];memset (has, false, sizeof (have)); for (int i = 0; i < n; i++) Has[num[i] = true;for (int i = 1; i < = N; i++) if (!has[i]) return False;return true;} void DFS (int idx, int cnt)//subscript to IDX, get CNT number {if (cnt + LEN-IDX < N)//If the length of the remaining string cannot get N number then return to RETURN;IF (flag)//Find feasible solution then return Retu Rn;if (idx >= len)//Search to Final judgment and return {if (cnt = = n && ok ()) flag = True;return;} NUM[CNT] = s[idx]-' 0 '; Single digit if (!vis[num[cnt]])//The current number is not obtained then recorded and continued search {VIS[NUM[CNT]] = True;dfs (idx + 1, cnt + 1); if (flag) return;vis[num[cnt]] = false;} if (idx < len-1) {NUM[CNT] = ten * (S[idx]-' 0 ') + S[IDX + 1]-' 0 ';//10-digit if (num[cnt] <= n && num[cnt] > 9) {if (!vis[num[cnt]) {DFS (idx + 2, CNT + 1), if (flag) return;vis[num[cnt]] = false;}}} return;} int main () {while (scanf ("%s", s)! = EOF) {flag = False;memset (Vis, false, sizeof (VIS)), memset (num, 0, sizeof (num)); len = str Len (s); if (len > 9) n = 9 + (len-9)/2;elsen = Len;dfs (0, 0), for (int i = 0; i < n-1; i++) printf ("%d", Num[i]);p rintf ("%d\n", Num[n-1]);}}
Cheating whistle-blowers
Time limit: 1000ms
Memory: 65536K
In view of the congestion in our city, the municipal traffic control department has been hearing the decision to place automatic parking charge system on both sides of the road. When the vehicle into the parking space, the system will be equipped with a camera to capture the vehicle image, by identifying the number of license plate, the letter sequence to identify the license plate, by connecting the DMV vehicle Information database to confirm the vehicle, the deduction fee.
The play of wits is generally started from here ...
Some owners can avoid the payment of parking fees by blocking one or more numbers and letters on the license plate while stopping the identification of the system.
Car owners This is simply a one-stop to get out a world puzzle has wood?! Management is on the one hand, the technical solution is the kingly ah.
Such a difficult project had to be handed over to the Garlic Guest lab. D God is responsible for identifying the color, E God is responsible for model identification, the possible license plate range is so little reduced. As an intern of garlic is also arduous task, will already exist in the vehicle database can match with the current known information to screen out the license plate information, this is the first step of the whole project AH, the importance I will not say more, come on.
Input
The first line of the input file contains a 9-character sequence of characters that represents the recognition.
The recognizable characters are displayed in uppercase letters and numbers, and "*" denotes characters that are not recognized because they are obscured.
The second line of the input file contains an integer n (1≤n≤1000)-The number of license plate information in the motor vehicle database.
Next n rows, containing the corresponding license plate information, one per line.
The license information is a string of length 9 that contains only numbers and uppercase letters. All license information is guaranteed to be different.
Output
The first behavior of the output file is an integer k (0≤k≤n)-the number of licenses that meet the given requirements.
The next K-line, output all possible license plate information.
Example 1
Input:
A**1mp19*4a001mp199e885ee098a111mp199kt7351ttb
Output:
2a001mp199a111mp199
Topic Analysis: Small simulation, directly engage
#include <cstdio> #include <cstring>char s[1005][10], Re[1005][10];int main () { char t[10]; while (scanf ("%s", t)! = EOF) { memset (re, 0, sizeof (re)); int n; scanf ("%d", &n); for (int i = 0; i < n; i++) scanf ("%s", S[i]); int ans = 0; for (int i = 0; i < n; i++) { int J; for (j = 0; J < 9; j + +) { if (t[j] = = ' * ') continue; if (t[j]! = S[i][j]) break ; } if (j = = 9) strcpy (Re[ans + +], s[i]); } printf ("%d\n", ans); for (int i = 0; i < ans; i++) printf ("%s\n", Re[i]);} }
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Garlic Trail Test (BCD)