• <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>
            Welcome to Leon's Blog  
            日歷
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567
            統計
            • 隨筆 - 30
            • 文章 - 0
            • 評論 - 51
            • 引用 - 0

            導航

            常用鏈接

            留言簿(4)

            隨筆分類

            隨筆檔案

            ACM

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

             

                 摘要:     這幾天一直在修改這道題,一直都改不對,老是錯誤,提交不成功,我把自己的代碼貼出來讓大家幫忙看看,在這里謝過了! #include <stdio.h>#include <string.h>#include <stdlib.h>int result[4];int reNumbe...  閱讀全文
            posted @ 2008-06-29 16:09 Leon916 閱讀(1098) | 評論 (6)編輯 收藏
             
                  昨天開始做1423題,早上剛剛ac。其實這道題有好幾種方法,后來看了大家討論才去做的,不算是自己獨立思考。
                 第一種方法是根據stirling逼近來做,《計算機程序設計藝術》《算法導論》中給出了公式。
                 第二種是是取對數,寫了一個但是總是超時,后來看了這篇blog,后悔自己當初為什么不想辦法改進自己的方法。
                 算是留個紀念,下次注意!
            posted @ 2008-06-04 08:56 Leon916 閱讀(136) | 評論 (0)編輯 收藏
             
                 今天做完1006題,第一次用枚舉法,但是時間復雜度大,后來看到帖子說是用中國余數法。自己試著也寫了一個,但是用時也過大,現在把代碼貼出來,請大家幫忙改一改啊!謝謝了!
             1#include <stdio.h>
             2
             3int main(int argc, char* argv[])
             4{
             5    int p,e,i,d, index;
             6    int day;
             7    int x = 28*33*6;
             8    int y = 23*33*19;
             9    int z = 23*28*2;
            10    index = 0;
            11    
            12
            13    do
            14    {
            15        scanf("%d %d %d %d"&p,&e, &i, &d);
            16        if(p == -1 && e == -1 && i == -1 && d == -1)
            17            break;
            18        p = p%23;
            19        e = e%28;
            20        i = i%33;
            21        day = (p*+ e*+ i*z) % 21252;
            22        if(day == d)
            23            day += 21252;
            24        printf("Case %d: the next triple peak occurs in %d days.\n"++index,day->= 0 ? day-d : day-d+21252);
            25    }
            while(1); 
            26    return 0;
            27}
            posted @ 2008-05-30 20:43 Leon916 閱讀(1223) | 評論 (4)編輯 收藏
             
                 這是我做1005題的代碼,希望大家看完之后能給予指導。
               
             1#include <stdio.h>
             2
             3#define PI 3.141592
             4
             5int Caculate(float x, float y)
             6{
             7    int r = (int)((x*+ y*y) * PI / 100);
             8    return  r*100 >= (x*+ y*y)*PI ? r : r+1;
             9}

            10
            11int main(int argc, char* argv[])
            12{
            13    int n, i;
            14    float x,y;
            15    int year;
            16    scanf("%d"&n);
            17    for(i = 1; i <= n; i++)
            18    {
            19        scanf("%f %f"&x, &y);
            20        year = Caculate(x, y);
            21        printf("Property %d: This property will begin eroding in year %d.\n", i, year);
            22    }

            23    printf("END OF OUTPUT.\n");
            24    
            25    return 0;
            26}

            27
            28
            posted @ 2008-05-29 08:40 Leon916 閱讀(1208) | 評論 (4)編輯 收藏
             
                今天提交了1004,但總覺得題意好像沒有這么簡單。先貼上自己的代碼,大家是怎么思考這道題的?

             1#include <stdio.h>
             2int main(int argc, char* argv[])
             3{
             4    int i;
             5    float sum = 0, temp;
             6    for(i = 0; i < 12; i++)
             7    {
             8        scanf("%f"&temp);
             9        sum += temp;
            10    }

            11    printf("$%.2f", sum/12);
            12    return 0;
            13}
            posted @ 2008-05-25 20:12 Leon916 閱讀(950) | 評論 (2)編輯 收藏
             
                今天做的這道題感覺上面很奇怪,按照題目要求寫了代碼,但總覺得哪里有什么地方不對,還請大家多多指教!
             1#include <stdio.h>
             2int main(int argc, char* argv[])
             3{
             4    float s,sum = 0;
             5    int i,j;
             6    while(scanf("%f"&sum) == 1)
             7    {
             8        if(sum != 0)
             9        {
            10            j = 2; s = 0;
            11            while(s < sum)
            12            {
            13                s += 1.0/j;
            14                j++;
            15            }

            16            printf("%d card(s)\n", j-2);
            17        }

            18        else
            19            break;
            20    }

            21        return 0;
            22}
            posted @ 2008-05-24 10:35 Leon916 閱讀(1205) | 評論 (8)編輯 收藏
             
                 摘要:       這道題我做的很郁悶,代碼也寫的不好、很長,方法也一般,有點麻煩,自己都覺得很爛,在提交的時候,發現別人的代碼寫的很簡練,但是不知道自己該怎么改進,希望大家多多提意見,謝謝大家了!     1#include <string.h>  2#include&...  閱讀全文
            posted @ 2008-05-22 14:16 Leon916 閱讀(1554) | 評論 (1)編輯 收藏
             
                 昨天晚上寫完了這道題,早上過來提交。 主要用到了插入排序算法,并且參看了桶排序算法,如果大家有什么好的想法,希望能夠共享一下,嘿嘿!我的代碼有哪里寫的不好,也請大家指教!
             1#include <stdlib.h>
             2#include <stdio.h>
             3typedef struct dNANumber
             4{
             5    char ch[100];
             6    int count;
             7}
            DNANumber;
             8
             9void Sort(DNANumber *arr, int rows)
            10{
            11    int i, j;
            12    DNANumber temp;
            13    for(i = 1; i < rows; i++)
            14    {
            15        temp = arr[i];
            16        for(j = i-1; j >= 0; j--)
            17        {
            18            if(arr[j].count > temp.count)
            19                arr[j+1= arr[j];
            20            else 
            21                break;
            22        }

            23        arr[j+1= temp;
            24    }

            25    return;
            26}

            27
            28int Index(char ch)
            29{
            30    switch(ch)
            31    {
            32    case 'A':
            33        return 0;
            34    case 'C':
            35        return 1;
            36    case 'G':
            37        return 2;
            38    case 'T':
            39        return 3;
            40    }

            41}

            42
            43void CountNumber(DNANumber *dna, int length)
            44{
            45    int count = 0;
            46    int letter[4= {0,0,0,0};
            47    int i, j;
            48    int temp;
            49    
            50    for(i = 0; i < length; i++)
            51    {
            52        letter[Index(dna->ch[i])]++;
            53    }

            54
            55    for(i = length-1; i >= 0; i--)
            56    {
            57        temp = Index(dna->ch[i]);
            58        for(j = temp+1; j < 4; j++)
            59        {
            60            count += letter[j];
            61        }

            62        letter[temp]--;            
            63    }

            64    dna->count = count;
            65    return;
            66}

            67int main(int argc, char* argv[])
            68{
            69    int length = 0, rows = 0;
            70    int i;
            71    DNANumber dnaArray[10000];
            72    //DNANumber *dna;
            73
            74    scanf("%d %d"&length, &rows);
            75    for(i = 0; i < rows; i++)
            76    {
            77        dnaArray[i].count=0;
            78        scanf("%s", dnaArray[i].ch);
            79        CountNumber(&dnaArray[i], length);        
            80    }

            81
            82    Sort(dnaArray, rows);
            83
            84    for(i = 0; i < rows; i++)
            85    {
            86        printf("%s\n", dnaArray[i].ch);
            87    }

            88    return 0;
            89}

            90
            91
            92

            posted @ 2008-05-20 08:24 Leon916 閱讀(1234) | 評論 (1)編輯 收藏
             

               在上周開始做北大acm1002題,經過幾天的分析和參考別人的代碼,最后終于提交成功了。在這里把代碼貼出來,和大家分享,也懇請大家指出寫不好的地方。在網上搜到了另外一個人對這道題的解法,他是解法,推薦大家看看。

             1#include <stdlib.h>
             2#include <stdio.h>
             3typedef int TelNumber;
             4int toNumber[26= {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,-1,7,7,8,8,8,9,9,9,-1};
             5
             6void SortNumber(TelNumber *tel, int left, int right)
             7{
             8    int j,i;
             9    TelNumber temp;
            10    do
            11    {
            12        i = left;
            13        j = right;
            14        temp = tel[(i+j)/2];
            15        do
            16        {
            17            while(tel[i] < temp) i++;
            18            while(tel[j] > temp) j--;
            19            if(i > j)
            20                break;
            21            if(i < j)
            22            {
            23                TelNumber t = tel[i];
            24                tel[i] = tel[j];
            25                tel[j] = t;
            26            }

            27            i++;j--;
            28        }
            while(i <= j);
            29        
            30        if(j-left <= right -i)
            31        {
            32            if(left < j)
            33                SortNumber(tel,left, j);
            34            left = i;
            35        }

            36        else
            37        {
            38            if(i < right)
            39                SortNumber(tel, i, right);
            40            right = j;
            41        }

            42    }
            while(left < right);
            43}

            44
            45int main(int argc, char* argv[])
            46{
            47    int count;
            48    int i;
            49    int t = 1;
            50    int bSame = 0;
            51    TelNumber tel[100000];
            52    scanf("%d\n"&count);
            53    for( i = 0; i < count;i++)
            54    {
            55        char ch;
            56        tel[i] = 0;
            57        while( ch = getchar(), ch != '\n')
            58        {
            59            if(ch == '-')
            60                continue;
            61            else if (ch >= '0' && ch <= '9')
            62                tel[i] = tel[i]*10 + (ch-'0');
            63            else if((ch >= 'A' && ch <= 'P'|| (ch >= 'R' && ch <= 'Y'))
            64                tel[i] = tel[i]*10 + toNumber[ch-'A'];
            65        }

            66    }

            67
            68    SortNumber(tel, 0, count-1);
            69    for(i = 0; i < count;)
            70    {
            71        for(t = i+1; (t < count) && (tel[i] == tel[t]); t++)
            72            ;
            73        if(t-> 1)
            74        {
            75            bSame = 1;
            76            printf("%03d-%04d %d\n", tel[i]/10000, tel[i]%10000, t-i);
            77        }

            78        i=t;
            79    }

            80    if(bSame==0)
            81         printf("No duplicates.\n");
            82    return 1;
            83}
            posted @ 2008-05-19 10:44 Leon916 閱讀(1500) | 評論 (4)編輯 收藏
             
                 摘要: 今天下午做了一道acm的題,提交了10次都是WA,所以想請大家幫我看看到底哪里不正確,程序哪里寫的不好!謝謝大家了!代碼:   1#include <stdlib.h>  2#include <stdio.h>  3typedef struct telNumber ...  閱讀全文
            posted @ 2008-05-15 19:29 Leon916 閱讀(229) | 評論 (0)編輯 收藏
            僅列出標題
            共3頁: 1 2 3 
             
            Copyright © Leon916 Powered by: 博客園 模板提供:滬江博客
            精品久久久久久无码人妻热| 欧美无乱码久久久免费午夜一区二区三区中文字幕| 久久精品中文字幕一区| 欧美精品一本久久男人的天堂| 久久久久亚洲av毛片大| 国内精品久久九九国产精品| 久久夜色精品国产亚洲| 久久亚洲色一区二区三区| 久久久SS麻豆欧美国产日韩| 久久91精品国产91久久麻豆| 久久久久婷婷| 狠狠久久综合| 亚洲国产精品无码久久久秋霞2 | 伊人久久大香线蕉av一区| 久久精品一区二区影院| 久久久久久国产精品无码下载| 热re99久久精品国产99热| 国内高清久久久久久| 久久国产香蕉一区精品| 日本欧美久久久久免费播放网| 香蕉久久夜色精品国产2020| 久久久午夜精品| 国内精品久久久久久麻豆| 97久久精品午夜一区二区| 久久国产精品久久精品国产| 亚洲熟妇无码另类久久久| 国产精品免费久久久久电影网| A级毛片无码久久精品免费| 亚洲精品乱码久久久久66| 色综合久久中文字幕综合网| 国产精品美女久久久免费| 国内精品久久久久久99| 青青草原综合久久| WWW婷婷AV久久久影片| 久久人人爽人人爽人人爽| 女人高潮久久久叫人喷水| 热久久国产欧美一区二区精品| 国产AV影片久久久久久| 97精品国产97久久久久久免费 | MM131亚洲国产美女久久| 欧洲成人午夜精品无码区久久 |