ZOJ3818-Pretty Poem (brute force enumeration), zoj3818-prettypoem

Source: Internet
Author: User

ZOJ3818-Pretty Poem (brute force enumeration), zoj3818-prettypoem

Question Link


Question: Check whether the given string conforms to the ABABA or ABABCAB format. If Yes, output Yes. If No, No.

Idea: enumerate the lengths of A and B in A brute force mode. Then, subtract the length of AB three times from the length, that is, the length of C, to check whether the combined string is equal to the given one. Here, the substr function in string is a good thing.

Code:

#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>using namespace std;char str[55];int main() {    int cas;    scanf("%d", &cas);    while (cas--) {        scanf("%s", str);         string s;        int len = strlen(str);        for (int i = 0; i < len; i++)            if (isupper(str[i]) || islower(str[i]))                s += str[i];        len = s.length();        int flag = 0;        for (int i = 1; i < len / 2 && !flag; i++) {            for (int j = 1; j < len / 2 && !flag; j++) {                string A = s.substr(0, i);                 string B = s.substr(i, j);                 if (A == B)                     continue;                if (A + B + A + B + A == s) {                    flag = 1;                    break;                }                if (len - (i + j) * 3 > 0) {                    string AB = A + B;                     string C = s.substr(2 * (i + j), len - (i + j) * 3);                     if (A == C || B == C)                        continue;                    if (AB + AB + C + AB == s) {                        flag = 1;                         break;                     }                }             }         }         if (flag)            printf("Yes\n");        else            printf("No\n");     }    return 0;}



Hdu 1407 is an amazing question. No matter how hard I create a table or use brute force enumeration, I still feel depressed. I think the same is true of AC. http: // acm

// Direct violence. 280 + MS --
# Include <stdio. h>
Void main ()
{
Int n, I, j, k;
While (scanf ("% d", & n )! = EOF)
{
For (I = 1; I <100; I ++)
{
For (j = 1; j <100; j ++)
{
For (k = 1; k <100; k ++)
{
If (I * I + j * j + k * k = n)
{
Printf ("% d \ n", I, j, k );
Break;
}
}
If (I * I + j * j + k * k = n)
Break;
}
If (I * I + j * j + k * k = n)
Break;
}
}
}

How to use C language to write a brute force cracking software forcibly enumerative cracking website page Login Password

Send the form directly, check the HTML source code, and then check the Form format, name field, and connect to the server using socket, continuously send the form to the target webpage of the server until the returned page is a successful page, recording the content of the form used ..... For more information, see socket programming and the HTTP protocol. As long as you send a form request to the server according to the HTTP protocol, there will be a response. The browser sends an application to the server according to the HTTP protocol... Alternatively, you can install a network monitoring software to check what your computer has sent to the server. You just need to write a ticket according to other people's documents...
 

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.