5-1 ~ 5-11

//5-1 UVa 10474    
/*  
int Marble[10005];  
int T, Q;  
  
void Judge(int q) {  
    int i;  
    for(i = 1; i <= T; i++) {  
        if(Marble[i] == q) break;  
    }  
    if(i != T+1) printf("%d found at %d\n", q, i);  
    else printf("%d not found\n", q);  
}  
  
int main() {  
    int kase = 0;  
    //In();  
    //Out();  
    while(scanf("%d%d", &T, &Q) == 2 && T) {  
        printf("CASE# %d:\n", ++kase);  
        Clear(Marble, 0);  
        for(int i = 1; i <= T; i++) scanf("%d", &Marble[i]);  
        sort(Marble+1, Marble+T+1);  
        for(int i = 1; i <= Q; i++) {  
            int query;  
            scanf("%d", &query);  
            Judge(query);  
        }  
    }  
    return 0;  
}*/    
    
int n, q;    
int a[maxn];    
    
int main() {    
    int kase = 0;    
    //In();    
    //Out();    
    while(scanf("%d%d", &n, &q) == 2 && n) {    
        printf("CASE# %d:\n", ++kase);    
        Clear(a, 0);    
        For(0, n) scanf("%d", &a[i]);    
        sort(a, a+n);    
        while(q--) {    
            int x;    
            scanf("%d", &x);    
            int p = lower_bound(a, a+n, x) - a;    
            //printf("p = %d\n", p);    
            if(a[p] == x) printf("%d found at %d\n", x, p+1);    
            else printf("%d not found\n", x);    
        }    
    }    
    return 0;    
}    
/*  
1.q只表示次数,用while较好。  
2.lower_bound返回大于等于x的第一个位置,没找到则返回上界,二分查找蛮快的。  
3.即使从1开始编号,用0记录也挺方便的。  
*/    
//5-2 UVa 101    
/*struct A {  
    int cnt = 0;  
    int d[25];  
}a[25];  
int n;  
int q;  
  
int Find(int x) {  
    for(int i = 0; i < n; i++) {  
        for(int j = 0; j < a[i].cnt; j++) {  
            if(a[i].d[j] == x) {  
                q = j;  
                return i;  
            }  
        }  
    }  
}  
  
void My_clear(int x) {  
    int p = Find(x);  
    int c = a[p].cnt;  
    for(int i = q+1; i < c; i++) {  
        int val = a[p].d[i];  
        a[val].d[a[val].cnt++] = val;  
        a[p].cnt--;  
    }  
}  
  
void Move(int x, int y) {  
    int p1, p2;  
    p2 = Find(y);  
    p1 = Find(x);  
    int c = a[p1].cnt;  
    for(int i = q; i < c; i++) {  
        int val = a[p1].d[i];  
        a[p2].d[a[p2].cnt++] = val;  
        a[p1].cnt--;  
    }  
}  
  
void Print() {  
    for(int i = 0; i < n; i++) {  
        printf("%d:", i);  
        for(int j = 0; j < a[i].cnt; j++)  
            printf(" %d", a[i].d[j]);  
        printf("\n");  
    }  
}  
  
int main() {  
    //In();  
    //Out();  
    scanf("%d", &n);  
    For(0, n) a[i].d[a[i].cnt++] = i; //Print();  
    char s1[5], s2[5];  
    int x, y;  
    scanf("%s%d%s%d", s1, &x, s2, &y);  
    while(1) {  
        int p1 = Find(x), p2 = Find(y);  
        if(p1 == p2) goto there;  
        if(s1[0] == 'm') My_clear(x);  
        if(s2[1] == 'n') My_clear(y);  
        Move(x, y);  
        there:  
        scanf("%s", s1);  
        if(s1[0] == 'q') break;  
        scanf("%d%s%d", &x, s2, &y);  
        //Print();  
        //puts("");  
    }  
    Print();  
    return 0;  
}*/    
vector<int> ivec[30];    
int n;    
    
void Find(int x, int &p, int &h) {    
    for(p = 0; p < n; p++)    
        for(h = 0; h < ivec[p].size(); h++)    
            if(ivec[p][h] == x) return;    
}    
    
void My_Clear(int p, int h) {    
    for(int i = h+1; i < ivec[p].size(); i++) {    
        int x = ivec[p][i];    
        ivec[x].push_back(x);    
    }    
    ivec[p].resize(h+1);    
}    
    
void Move(int p1, int h1, int p2) {    
    for(int i = h1; i < ivec[p1].size(); i++)    
        ivec[p2].push_back(ivec[p1][i]);    
    ivec[p1].resize(h1);    
}    
    
void Print() {    
    for(int i = 0; i < n; i++) {    
        printf("%d:", i);    
        for(int j = 0; j < ivec[i].size(); j++)    
            printf(" %d", ivec[i][j]);    
        printf("\n");    
    }    
}    
    
int main() {    
    int p1, p2, h1, h2, x, y;    
    //In(); Out();    
    cin >> n;    
    For(0, n) ivec[i].push_back(i);    
    string s1, s2;    
    while(cin >> s1 >> x >> s2 >> y) {    
        Find(x, p1, h1);    
        Find(y, p2, h2);    
        if(p1 == p2) continue;    
        if(s1 == "move") My_Clear(p1, h1);    
        if(s2 == "onto") My_Clear(p2, h2);    
        Move(p1, h1, p2);    
    }    
    Print();    
    return 0;    
}    
/*  
1.vector确实方便,自带size,resize,pop_back,empty,clear。  
2.提取指令的共同点  
3.通过传引用的方式来获得多个值  
*/    
//5-3 UVa 10815    
int main() {    
    string s;    
    set<string> sset;    
    //In(); Out();    
    Close();    
    while(cin >> s) {    
        for(int i = 0; i < s.size(); i++) {    
            if(isalpha(s[i])) s[i] = tolower(s[i]);    
            else s[i] = ' ';    
        }    
        stringstream ss(s);    
        while(ss >> s) sset.insert(s);    
    }    
    for(set<string>::iterator i = sset.begin(); i != sset.end(); i++)    
        cout << *i << endl;    
    return 0;    
}    
/*  
1.先将非字母转化为空格,利用string输入对空格不敏感的特性,巧妙使用了sstream去除了空格。  
2.有可能中间有空格所以用while输入.  
3.set优点:set不用查重,作为有序的关联容器无需排序。  
*/    
//5-4 UVa 156  
string stand(string s) {  
    for(int i = 0; i < s.size(); i++) s[i] = tolower(s[i]);  
    sort(s.begin(), s.end());  
    return s;  
}  
  
int main() {  
    string s;  
    map<string, int> dict;  
    vector<string> svec;  
    Close();  
    while(cin >> s) {  
        if(s == "#") break;  
        dict[stand(s)]++;  
        svec.push_back(s);  
    }  
    sort(svec.begin(), svec.end());  
    for(int i = 0; i < svec.size(); i++)  
        if(dict[stand(svec[i])] == 1) cout << svec[i] << endl;  
    return 0;  
}  
  
/* 
1.这题感觉没什么好说的诶,map<string, int>,作为高级数组来使用。 
2.map的操作有count,find,上下界,insert,remove。 
3.map提供了[],使他更像数组了,关联数组。 
*/  
//5-5 UVa 12096  
typedef set<int> Set;  
map<Set, int> IDcache;  
vector<Set> Setcache;  
  
int ID(Set x) {  
    if(IDcache.count(x)) return IDcache[x];  
    Setcache.push_back(x);  
    return IDcache[x] = Setcache.size()-1;//id代表他在vector中的下表  
}  
  
int main() {  
    int T;  
    //Close();  
    //In(); Out();  
    cin >> T;  
    while(T--) {  
        stack<int> s;  
        int n;  
        cin >> n;  
        while(n--) {  
            string op;  
            cin >> op;  
            if(op[0] == 'P') {  
                s.push(ID(Set()));  
            }  
            else if(op[0] == 'D') s.push(s.top());  
            else {  
                Set x1 = Setcache[s.top()]; s.pop();  
                Set x2 = Setcache[s.top()]; s.pop();  
                Set x;  
                if(op[0] == 'U') set_union(ALL(x1), ALL(x2), INS(x));  
                if(op[0] == 'I') set_intersection(ALL(x1), ALL(x2), INS(x));  
                if(op[0] == 'A') { x = x2; x.insert(ID(x1)); }  
                s.push(ID(x));  
            }  
            cout << Setcache[s.top()].size() << endl;  
        }  
        cout << "***" << endl;  
    }  
    return 0;  
}  
/* 
1.将集合映射成vector中的下标 
*/  
//5-6 UVa 540  
int main() {  
    int t, kase = 1;  
    //In(); Out();  
    Close();  
    while(cin >> t) {  
        map<int, int> team;  
        if(!t) break;  
        for(int i = 0; i < t; i++) {  
            int n;  
            cin >> n;  
            while(n--) {  
                int num;  
                cin >> num;  
                team[num] = i;  
            }  
        }  
        string op;  
        cout << "Scenario #" << kase++ << endl;  
        queue<int> Q, q[maxn];  
        while(cin >> op) {  
            if(op[0] == 'S') break;  
            else if(op[0] == 'E') {  
                int num;  
                cin >> num;  
                int t = team[num];  
                if(q[t].empty()) Q.push(t);  
                q[t].push(num);  
            }  
            else {  
                int t = Q.front();  
                cout << q[t].front() << endl;  
                q[t].pop();  
                if(q[t].empty()) Q.pop();  
            }  
        }  
        cout << endl;  
    }  
}  
/* 
1.再次体现了映射的作用。。。。 
*/  
//5-7 UVa 136  
    const LL fac[] = {2, 3, 5};  
      
    int main() {  
        set<LL> ugly;  
        priority_queue<LL, vector<LL>, greater<LL> > pq;  
        ugly.insert(1);  
        pq.push(1);  
        for(int i = 1; ;i++) {  
            LL x = pq.top();  
            pq.pop();  
            if(i == 1500) {  
                cout << "The 1500'th ugly number is " << x << '.' << endl;  
                break;  
            }  
            for(int j = 0; j < 3; j++) {  
                LL n = x*fac[j];  
                if(ugly.find(n) == ugly.end()) { ugly.insert(n); pq.push(n); }  
            }  
        }  
        return 0;  
    }  
    /* 
    1.利用了set的查重。 
    2.使用优先队列,能够从小到大取数。 
    */  
//5-8 UVa 400  
string filename[maxn];  
  
int main() {  
    int n;  
    Close();  
    In(); Out();  
    while(cin >> n) {  
        int Maxlen = 0;  
        for(int i = 0; i < n; i++) {  
            cin >> filename[i];  
            Maxlen = max((int)filename[i].size(), Maxlen);  
        }  
        int column = 62/(Maxlen+2);  
        int row = (n-1)/column + 1;  
        sort(filename, filename+n);  
        cout << "------------------------------------------------------------\n";  
        for(int i = 0; i < row; i++) {  
            for(int j = i, k = 0; j < n; j += row, k++) {  
                cout.setf(ios::left);  
                cout.width(Maxlen+2);  
                if(k == column-1) cout.width(Maxlen);  
                cout << filename[j];  
            }  
            cout << endl;  
        }  
    }  
    return 0;  
}  
/* 
1.ceil除法row = (n-1)/column + 1。 
2.vector的优点体现在大小改变上。 
*/  
//5-9 Uva 1592
int a[10005][15], cnt;
map<string, int> id;

int ID(string s) {
    if(!id.count(s)) id[s] = cnt++;
    return id[s];
}

void Solve(int n, int m) {
    for(int c1 = 0; c1 < m; c1++)
    for(int c2 = c1+1; c2 < m; c2++) {
        map<pair<int, int>, int> DB;
        for(int r = 0; r < n; r++) {
            pair<int, int> cc(a[r][c1], a[r][c2]);
            if(DB.count(cc)) {
                cout << "NO\n";
                cout << DB[cc]+1 << ' ' << r+1 << endl << c1+1 << ' ' << c2+1 << endl;
                return;
            }
            else DB[cc] = r;
        }
    }
    cout << "YES\n";
}

int main() {
    int n, m;
    string s;
    CLOSE();
    //IN(); OUT();
    while(cin >> n >> m) {
        getline(cin, s);
        cnt = 0;
        id.clear();
        for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++) {
            if(j+1 != m) getline(cin, s, ',');
            else getline(cin, s);
            a[i][j] = ID(s);
        }
        Solve(n, m);
    }
    return 0;
}
//5-10 Uva 207
/*
1.Any player who is disqualied stops playing at the time of the disqualication.    
2. if 10 players are tied for 70th place, then 79 players make the 36-hole cut.    
3.There will be only one winner of this tournament.    
4.Only the low 70 non-amateur places and ties earn prize money.    
5.the order among disquali ed players is unimportant.     
6.Assume that at least 70 players will make the 36-hole cut.    
*/
struct Player {    
    char name[25];    
    int sc[4], rnk, sc2, sc4;    
    bool dq, amateur, t;    
    double price;    
}p[150];    
double Price[70], purse;    
int n;    
    
void Print() {    
    printf("Player Name          Place     RD1  RD2  RD3  RD4  TOTAL     Money Won\n");    
    printf("-----------------------------------------------------------------------\n");    
    for(int i = 0; i < n; i++) {    
        printf("%-21s", p[i].name);    
        if(p[i].dq) printf("          ");    
        else {    
            char t[5];    
            sprintf(t, "%d%c", p[i].rnk, p[i].t?'T':' ');    
            printf("%-10s", t);    
        }    
        for(int j = 0, flag = 1; j < 4; j++) {    
            if(p[i].sc[j] >= maxn) flag = 0;    
            if(flag) printf("%-5d", p[i].sc[j]);    
            else printf("     ");    
        }    
        if(p[i].dq) printf("DQ");    
        else if(!p[i].amateur) printf("%-10d", p[i].sc4);    
        else printf("%d", p[i].sc4);    
        if(p[i].dq || p[i].amateur) puts("");    
        else printf("$%9.2lf\n", p[i].price);    
    }    
}    
    
void Read_Price() {    
    scanf("%lf", &purse);    
    for(int i = 0; i < 70; i++) {    
        scanf("%lf", &Price[i]);    
        Price[i] = Price[i] / 100.0 * purse;    
    }    
}    
    
void Read_Records() {    
    memset(p, 0, sizeof(p));    
    scanf("%d\n", &n);    
    char s[40];    
    for(int i = 0; i < n; i++) {    
        fgets(p[i].name, 20, stdin);    
        if(strchr(p[i].name, '*')) p[i].amateur = true;    
        for(int j = 0; j < 4; j++) {    
            if(!scanf("%d", &p[i].sc[j])) {    
                p[i].dq = true;    
                p[i].sc[j] = (4-j) * maxn;    
                break;    
            }    
        }    
        fgets(s, 40, stdin);    
        for(int j = 0; j < 4; j++) {    
            if(j < 2) p[i].sc2 += p[i].sc[j];    
            p[i].sc4 += p[i].sc[j];    
        }    
    }    
}    
    
bool cmp1(const Player &a, const Player &b) {    
    return a.sc2 < b.sc2;    
}    
    
bool cmp2(const Player &a, const Player &b) {    
    if(a.sc4 != b.sc4) return a.sc4 < b.sc4;    
    else return strcmp(a.name, b.name) < 0;    
}    
    
void Solve() {    
    sort(p, p+n, cmp1);    
    for(int i = 70; i < n; i++) if(p[i].sc2 != p[i-1].sc2) { n = i; break; } //Print();    
    sort(p, p+n, cmp2);    
    int i = 0, pnk = 0;    
    while(i < n) {    
        if(p[i].dq) break;    
        int cnt = 0, j = i;    
        int flag = 0;    
        double sum = 0.0;    
        while( j < n && p[i].sc4 == p[j].sc4) {    
            if(!p[j].amateur) {    
                cnt++;    
                if(pnk < 70) sum += Price[pnk++], flag = 1;    
            }    
            j++;    
        }    
        sum /= cnt;    
        int rnk = i+1;    
        while(i < j) {    
            p[i].rnk = rnk;    
            if(pnk > 69 && !flag) p[i].amateur = 1, p[i].t = false;    
            if(!p[i].amateur) p[i].price = sum, p[i].t = cnt>1;    
            i++;    
        }    
    }    
}    
    
int main() {    
    int T;    
    //IN(); OUT();    
    scanf("%d", &T);    
    while(T--) {    
        Read_Price();    
        Read_Records();    
        Solve();    
        Print();    
        if(T) printf("\n");    
    }    
    return 0;    
}    
/*  
char *strchr(const char *, char)返回首次出现_Val的位置的指针,返回的地址是被查找字符串指针开始的第一个与Val相同字符的指针,如果Str中不存在Val则返回NULL。  
char *fgets(char *buf, int bufsize, FILE *stream);  
如果文件中的该行,不足bufsize个字符,则读完该行就结束。  
1.scanf()函数有返回值且为int型。  
2.scanf()函数返回的值为:正确按指定格式输入变量的个数;也即能正确接收到值的变量个数。  
逗号运算的结合性是从左至右,完毕之后整个表达式的值是最后一个表达式的值。  
心态爆炸,这道题做了有整整3天,惨痛的教训告诉我,认真读题认真读题啊啊,以后每道题做之前必先读原题。。  
*/



//例题5-11 UVa814 The Letter Carrier's Rounds
//首先是我自己实现的,特傻,对输出顺序处理采用了队列。不该用流的地方也用了。
//我分了好几个函数来处理这题,结构虽然清晰了些,但缺点是用了太多全局的东西,初始化需要注意。
vector<vector<string> > name;
vector<map<string, int> > nid;
vector<string> dest;
map<string, int> did;
map<string, string> home;

pair<string, string> send;
vector<pair<string, string> > recv;
set<pair<string, string> > re;
vector<string> msg;

int DID(string &s) {
    if(did.count(s)) return did[s];
    else {
        dest.push_back(s);
        name.push_back(vector<string>());
        nid.push_back(map<string, int>());
        return did[s] = dest.size()-1;

    }
}

void NID2(string &s, int i) {
    if(!nid[i].count(s)) {
        name[i].push_back(s);
        nid[i][s] = name[i].size()-1;
    }
}

int NID(string &s, int i) {
    if(!nid[i].count(s)) return -1;
    else return nid[i][s];
}

void Read_Dsp() {
    string in;
    while(getline(cin, in)) {
        stringstream ss(in);
        string place, people;
        ss >> place;
        if(place == "*") return;
        ss >> place;
        int pid = DID(place);
        int n;
        ss >> n;
        while(n--) {
            ss >> people;
            home[people] = place;
            NID2(people, pid);
        }
    }
}

bool Read_Rcv() {
    string in;
    getline(cin, in);
    stringstream ss(in);
    string s, s1, s2;
    int flag = 1;
    recv.clear();
    re.clear();
    while(ss >> s) {
        if(s == "*") return false;
        int l;
        for(UI i = 0; i < s.size(); i++) if(s[i] == '@') { l = i+1; break; }
        string s1(s.substr(0, l-1)), s2(s.substr(l, s.size()-l));
        if(flag) {
            send = make_pair(s1, s2);
            flag = 0;
        }
        else {
            pair<string, string> p(s1, s2);
            if(!re.count(p)) {
                recv.push_back(make_pair(s1, s2));
                re.insert(p);
            }
        }
    }
    getchar();
    return true;
}

void Read_Msg() {
    msg.clear();
    string in;
    getline(cin, in);
    while(getline(cin, in)) {
        if(in == "*") return;
        msg.push_back(in);
    }
    getchar();
}

void Solve() {
    queue<int> Q;
    queue<string> q[1005];
    for(UI i = 0; i < recv.size(); i++) {
        int x = DID(recv[i].second);
        if(q[x].empty()) Q.push(x);
        q[x].push(recv[i].first);
    }
    while(!Q.empty()) {
        int x = Q.front();
        int flag = 0;
        cout << "Connection between " << send.second << " and " << dest[x] << endl;
        cout << "     HELO " << send.second << "\n     250\n";
        cout << "     MAIL FROM:<" << send.first << '@' << send.second << ">\n     250\n";
        while(!q[x].empty()) {
            string s = q[x].front(); q[x].pop();
            cout << "     RCPT TO:<" << s << '@' << dest[x] << ">\n     ";
            if(NID(s, x) == -1) cout << 550 << endl;
            else { flag = 1; cout << 250 << endl; }
        }
        if(flag) {
            cout << "     DATA\n     354\n";
            for(UI i = 0; i < msg.size(); i++) cout << "     " << msg[i] << endl;
            cout << "     .\n     250\n";
        }
        cout << "     QUIT\n     221\n";
        Q.pop();
    }
}

void Debug() {
    for(UI i = 0; i < dest.size(); i++) {
        cout << dest[i] << " :";
        int d = did[dest[i]];
        for(UI j = 0; j < name[d].size(); j++) {
            cout << ' ' << name[d][j];
        }
        cout << endl;
    }
}

void Debug2() {
    cout << send.first << " " << send.second << endl;
    for(UI i = 0; i < recv.size(); i++) cout << recv[i].first << " " << recv[i].second << endl;
}

void Debug3() {
    for(UI i = 0; i < msg.size(); i++) cout << msg[i] << endl;
}

int main() {
    //IN(); OUT();
    Read_Dsp(); //Debug();
    while(Read_Rcv()) {
        //Debug2();
        Read_Msg();
        //Debug3();
        Solve();
    }
    return 0;
}
//改进:
//1.数据读入不必用stringstream处省去
//2.msg读入,改vector存为直接连换行一起存储
//3.不必要进行map映射的地方省去,只需查重用set即可
using PSS = pair<string, string>;
set<string> MTA;

void Phase(string s, string &s1, string &s2) {
    int p = s.find('@');
    s1 = s.substr(0, p);
    s2 = s.substr(p+1);
}

void Solve() {
    string s, s1, s2;
    while(cin >> s && s != "*") {
        Phase(s, s1, s2);
        pair<string, PSS> send(s, PSS(s1, s2));
        map<string, vector<string> > recv;
        set<string> vis;
        vector<string> dest;
        while(cin >> s && s != "*") {
            Phase(s, s1, s2);
            if(!vis.count(s)) vis.insert(s);
            else continue;
            if(!recv.count(s2)) { dest.push_back(s2); recv[s2] = vector<string>(); }
            recv[s2].push_back(s1 + "@" + s2);
        }
        getline(cin, s);
        string msg;
        while(getline(cin, s) && s != "*") msg += "     " + s + "\n";
        for(UI i = 0; i < dest.size(); i++) {
            cout << "Connection between " << send.second.second << " and " << dest[i] << endl;
            cout << "     HELO " << send.second.second << "\n     250\n";
            cout << "     MAIL FROM:<" << send.first << ">\n     250\n";
            int flag = 0;
            for(UI j = 0; j < recv[dest[i]].size(); j++) {
                cout << "     RCPT TO:<" << recv[dest[i]][j] << ">\n     ";
                if( MTA.count( recv[dest[i]][j] ) ) { cout << "250\n"; flag = 1; }
                else cout << "550\n";
            }
            if(flag) {
                cout << "     DATA\n     354\n";
                cout << msg << "     .\n     250\n";
            }
            cout << "     QUIT\n     221\n";
        }
    }
}

int main() {
    //IN(); OUT();
    string place, name;
    while(cin >> place && place != "*") {
        int n;
        cin >> place >> n;
        while(n--) {
            cin >> name;
            MTA.insert(name+"@"+place);
        }
    }
    Solve();
    return 0;
}
/*
static const size_t npos = -1;

string.substr()
string substr (size_t pos = 0, size_t len = npos) const;
The substring is the portion of the object that starts at character position pos and spans len characters (or until the end of the string, whichever comes first).

string.find()
string (1)    size_t find (const string& str, size_t pos = 0) const noexcept;
c-string (2)    size_t find (const char* s, size_t pos = 0) const;
buffer (3)    size_t find (const char* s, size_t pos, size_type n) const;
character (4)    size_t find (char c, size_t pos = 0) const noexcept;
*/
今天听了阿斌学长讲了许多,我感觉学长希望表达的意思是通过思维方式的养成,可以提高自己的对问题的解决能力。具体而言就是面对一个问题是有套路的,以acm的题为例,解决一个acm题的步骤为读题->想题->敲题->调试->最后ac。读题过程可以通过sample的对照来帮助理解题意,调试过程,输出调试法,可以在一个子函数的入口及出口处printf变量的值进而判断函数是否有误,小黄鸭调试法,其实就是对程序的每一步进行讲解,看看是否有思维不够完善的地方。学长着重介绍的是想题的部分,他首先讲了一个例子,思考一个砖块有什么用,我的想法是性质决定用途,学长给出的思路是类比的方法,比如砖块是长方形的,长方形的物体有哪些,这些物体能有什么用呢,砖块是否也同样具有这些功能呢。遇到一个问题,首先观察是否做过类似的题,还有就是可以将自己的思维过程写在草稿纸上,人的思维是有限的,就像一个寄存器一般,当我们由浅入深的思考一个问题,如同一条路走到头,也许这条路中间的某个部分,往边上走走就是答案了,但是我们走到头时,往往会忘记我们在过程中的想法,所以在纸上记录下来就犹如有了一个内存,不仅可以方便我们从中间过程进行优化,也可以方便我们检查错误。学长还说到想题过程就如同一个解决搜索问题的过程,可以有许多种方法,例如记忆化搜索,Dfs等。学长认为养成思考问题套路的习惯能提高解题能力,但我感觉,要将这一套方法形成如同骑自行车一般随心所欲,大概需要大量的知识储备与题量基础吧。我这两天写的程序对现在的我来说属于比较繁琐的,上一道题让我明白了读题的重要性,这一道题则让我明白,不整理思路直接就上手写代码是错误的行为,事倍功半。














  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值