• <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ù)目最少的兩堆水果合并
                無聊花了茫茫長時(shí)間回憶priority_queue。。。長久不用,重載運(yùn)算符都不會寫了。。有空復(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;
            }
            日本久久久久亚洲中字幕| 久久无码精品一区二区三区| 久久99这里只有精品国产| A级毛片无码久久精品免费| 人妻精品久久久久中文字幕一冢本| 国产亚洲精久久久久久无码| 中文字幕久久亚洲一区| 国产一区二区三区久久精品| 青青草原综合久久大伊人导航 | 无码任你躁久久久久久| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 四虎国产精品成人免费久久| A狠狠久久蜜臀婷色中文网| 久久精品免费大片国产大片| 久久影院综合精品| 精品欧美一区二区三区久久久 | 久久99热狠狠色精品一区| 亚洲综合久久夜AV | 久久精品国产福利国产秒| 久久久久久国产精品免费无码| 性欧美大战久久久久久久| 久久久九九有精品国产| 国产成人精品久久二区二区| 久久国产精品一国产精品金尊| 久久久久久伊人高潮影院| 久久最新免费视频| 日韩中文久久| 日本欧美国产精品第一页久久| 国产欧美一区二区久久| 国产Av激情久久无码天堂| 久久丫精品国产亚洲av| 久久久久久人妻无码| 7777久久亚洲中文字幕| av无码久久久久久不卡网站| 久久精品亚洲中文字幕无码麻豆 | 久久精品国产亚洲AV不卡| 久久这里的只有是精品23| 色播久久人人爽人人爽人人片AV| 久久亚洲精品无码播放| 久久国产精品无| 国内高清久久久久久|