• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Uriel's Corner

            Research Associate @ Harvard University / Research Interests: Computer Vision, Biomedical Image Analysis, Machine Learning
            posts - 0, comments - 50, trackbacks - 0, articles - 594
            各種大水題。。
            1. 字符串的反碼
                大水不解釋
            //2011年吉林大學(xué)計(jì)算機(jī)研究生機(jī)試題 字符串的反碼
            #include<stdio.h>
            #include
            <stdlib.h>
            #include
            <string.h>

            int main() {
                
            int n, t, p;
                
            while(scanf("%d"&n), n) {
                    t 
            = n; p = 0;
                    
            while(t > 0) {
                        p 
            += t % 10;
                        t 
            /= 10;
                    }
                    printf(
            "%d ", p);
                    t 
            = n * n; p = 0;
                    
            while(t > 0) {
                        p 
            += t % 10;
                        t 
            /= 10;
                    }
                    printf(
            "%d\n", p);
                }
                
            return 0;
            }


            2. 數(shù)字之和
                
            大水不解釋
            //2011年吉林大學(xué)計(jì)算機(jī)研究生機(jī)試題 數(shù)字之和
            #include<stdio.h>
            #include
            <stdlib.h>
            #include
            <string.h>

            int main() {
                
            int n, t, p;
                
            while(scanf("%d"&n), n) {
                    t 
            = n; p = 0;
                    
            while(t > 0) {
                        p 
            += t % 10;
                        t 
            /= 10;
                    }
                    printf(
            "%d ", p);
                    t 
            = n * n; p = 0;
                    
            while(t > 0) {
                        p 
            += t % 10;
                        t 
            /= 10;
                    }
                    printf(
            "%d\n", p);
                }
                
            return 0;
            }


            3. 搬水果
                貪心,每次取數(shù)目最少的兩堆水果合并
                無聊花了茫茫長(zhǎng)時(shí)間回憶priority_queue。。。長(zhǎng)久不用,重載運(yùn)算符都不會(huì)寫了。。有空復(fù)習(xí)C++去。。
            //2011年吉林大學(xué)計(jì)算機(jī)研究生機(jī)試題 搬水果 
            #include<queue> 
            #include
            <stdio.h>
            #include
            <stdlib.h>
            #include
            <string.h>
            using namespace std;

            struct Node {
                
            int a;
                
            bool operator<(const Node &b) const {
                    
            return a > b.a;
                }
            };

            int main() {
                
            int n, a, b, ans;
                Node tp;
                
            while(scanf("%d"&n), n) {
                    priority_queue
            <Node> que;
                    
            while(n--) {
                        scanf(
            "%d"&a);
                        tp.a 
            = a;
                        que.push(tp);
                    }
                    ans 
            = 0;
                    
            while(que.size() > 1) {
                        a 
            = que.top().a; que.pop();
                        b 
            = que.top().a; que.pop();
                        ans 
            += a + b;
                        tp.a 
            = a + b;
                        que.push(tp);
                    }
                    printf(
            "%d\n", ans);
                }
                
            return 0;
            }


            4. 堆棧的使用
                STL stack水過
            //2011年吉林大學(xué)計(jì)算機(jī)研究生機(jī)試題 堆棧的使用
            #include<stack>
            #include
            <stdio.h>
            #include
            <stdlib.h>
            #include
            <string.h>
            using namespace std;

            int main() {
                
            int q, a;
                
            char ch[5];
                
            while(scanf("%d"&q), q) {
                    stack
            <int> stk;
                    
            while(q--) {
                        scanf(
            "%s", ch);
                        
            if(ch[0== 'A') {
                            
            if(stk.empty()) puts("E");
                            
            else
                                printf(
            "%d\n", stk.top());
                        }
                        
            else if(ch[0== 'O') {
                            
            if(!stk.empty()) stk.pop();
                        }
                        
            else if(ch[0== 'P') {
                            scanf(
            "%d"&a);
                            stk.push(a);
                        }
                    }
                    puts(
            "");
                }
                
            return 0;
            }


            5. 連通圖
                裸搜。。無聊回憶了下前向星~
            //2011年吉林大學(xué)計(jì)算機(jī)研究生機(jī)試題 連通圖
            #include<stdio.h>
            #include
            <stdlib.h>
            #include
            <string.h>
            #define N 5010
            #define M 5010

            int n, m, e, ev[M], vis[N], q[N], head[N], nxt[M];

            void addedge(int x, int y) {
                ev[e] 
            = y; nxt[e] = head[x];
                head[x] 
            = e++;
            }

            void BFS() {
                
            int l = 0, r = 1, i;
                q[
            0= 1;
                
            while(l < r) {
                    
            for(i = head[q[l]]; ~i; i = nxt[i]) {
                        
            if(!vis[ev[i]]) {
                            vis[ev[i]] 
            = 1;
                            q[r
            ++= ev[i];
                        }
                    }
                    
            ++l;
                }
            }

            int main() {
                
            int i, j;
                
            while(scanf("%d %d"&n, &m), n | m) {
                    e 
            = 0;
                    memset(head, 
            -1sizeof(head));
                    
            while(m--) {
                        scanf(
            "%d %d"&i, &j);
                        addedge(i, j);
                        addedge(j, i);
                    }
                    memset(vis, 
            0sizeof(vis));
                    BFS();
                    
            for(i = 1; i <= n; ++i) {
                        
            if(!vis[i]) break;
                    }
                    
            if(i <= n) puts("NO");
                    
            else
                        puts(
            "YES");
                }
                
            return 0;
            }
            久久久久亚洲?V成人无码| 久久久高清免费视频| 久久精品国产亚洲AV嫖农村妇女| 久久精品国产清自在天天线 | 国产综合成人久久大片91| 久久成人18免费网站| 久久精品国产99国产精品导航| 嫩草伊人久久精品少妇AV| 国产成人精品久久| 久久精品国产亚洲AV忘忧草18 | 久久笫一福利免费导航| 狠狠干狠狠久久| 久久天天躁狠狠躁夜夜不卡| 国产精品99久久精品| 伊人久久大香线蕉综合网站| 9久久9久久精品| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 亚洲欧洲精品成人久久奇米网| 无码国产69精品久久久久网站| 人人狠狠综合久久亚洲| 久久综合综合久久97色| 色综合久久无码中文字幕| 亚洲国产高清精品线久久| 国产成人久久久精品二区三区| 人妻精品久久久久中文字幕69| 久久综合久久综合亚洲| 狠狠色伊人久久精品综合网 | 久久亚洲中文字幕精品一区四 | 亚洲国产精品久久久久婷婷老年| 2021最新久久久视精品爱| 久久亚洲国产成人精品无码区| 99久久精品免费| 亚洲国产精品一区二区久久| 久久99精品国产麻豆宅宅| 久久天天躁狠狠躁夜夜avapp| 一本色道久久99一综合| 精品久久久无码人妻中文字幕| 久久中文字幕人妻丝袜| 99蜜桃臀久久久欧美精品网站| 久久人人爽人人爽人人片av麻烦| 久久精品国产亚洲AV香蕉|