• <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;
            }
            97久久综合精品久久久综合| 久久精品亚洲精品国产欧美| 久久频这里精品99香蕉久| 超级碰碰碰碰97久久久久| 久久精品国产亚洲av麻豆蜜芽| 乱亲女H秽乱长久久久| AAA级久久久精品无码区| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 精品国产乱码久久久久软件| 久久亚洲精品无码VA大香大香| 99久久99久久精品免费看蜜桃| 国产精品免费久久| 大香伊人久久精品一区二区| 国産精品久久久久久久| 久久精品国产亚洲AV无码麻豆| 久久久久久久久久免免费精品| 久久精品国产99久久无毒不卡| 久久99精品久久久久久秒播| 久久久久国产精品熟女影院| 亚洲精品tv久久久久| 丁香五月综合久久激情| 久久精品人人做人人爽电影蜜月| 久久精品三级视频| 99久久夜色精品国产网站| 国产精品99久久免费观看| 亚洲国产另类久久久精品| 久久人人爽人人精品视频| 久久精品无码免费不卡| 狠狠色综合网站久久久久久久| 国产一级持黄大片99久久| 国产精品毛片久久久久久久| 无码国内精品久久人妻蜜桃| 久久人人爽人人人人片av| 久久伊人中文无码| 日日狠狠久久偷偷色综合0| 久久综合九色综合欧美就去吻| 久久99精品久久久久久秒播| 蜜桃麻豆www久久国产精品| 亚洲?V乱码久久精品蜜桃| 亚洲日本va午夜中文字幕久久| 人妻无码精品久久亚瑟影视|