• <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>

            superman

            聚精會(huì)神搞建設(shè) 一心一意謀發(fā)展
            posts - 190, comments - 17, trackbacks - 0, articles - 0
               :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

             1 /* Accepted 1160 C++ 00:00.23 836K */
             2 #include <iostream>
             3 
             4 using namespace std;
             5 
             6 int main()
             7 {
             8     int N;
             9     cin >> N;
            10     
            11     while(N--)
            12     {
            13         int p, e, i, d, n = 0;
            14         while(cin >> p >> e >> i >> d)
            15         {
            16             if(p == -1 && e == -1 && i == -1 && d == - 1)
            17                 break;
            18             int x = (p * 5544 + i * 1288 + e * 14421% 21252 - d;
            19             while(x <= 0)
            20                 x += 21252;
            21             cout << "Case " << ++<< ": the next triple peak occurs in "
            22                  << x << " days." << endl;
            23         }
            24         if(N)
            25             cout << endl;
            26     }
            27     
            28     return 0;
            29 }
            30 

            posted @ 2008-04-13 14:55 superman 閱讀(223) | 評(píng)論 (0)編輯 收藏

             1 /* Accepted 1195 C++ 00:00.00 844K */
             2 #include <iostream>
             3 
             4 using namespace std;
             5 
             6 int main()
             7 {
             8     int n, m, fuse, sequence = 0;
             9     while((cin >> n >> m >> fuse) && n && m && fuse)
            10     {
            11         sequence++;
            12         cout << "Sequence " << sequence << endl;
            13         
            14         int c[21= {0};
            15         for(int i = 1; i <= n; i++)
            16             cin >> c[i];
            17         
            18         int cnt = 0, max = 0, t;
            19         bool state[21= {false}, blown = false;
            20         for(int i = 0; i < m; i++)
            21         {
            22             cin >> t;
            23             if(blown)
            24                 continue;
            25             
            26             state[t] ^= 1;
            27             max >?= cnt += (state[t] ? c[t] : -c[t]);
            28             
            29             if(cnt > fuse)
            30             {
            31                 blown = true;
            32                 cout << "Fuse was blown." << endl;
            33             }
            34         }
            35         if(blown == false)
            36             cout << "Fuse was not blown." << endl
            37                  << "Maximal power consumption was " << max << " amperes." << endl;
            38         cout << endl;
            39     }
            40     
            41     return 0;
            42 }
            43 

            posted @ 2008-04-13 09:50 superman 閱讀(303) | 評(píng)論 (0)編輯 收藏

             1 /* Accepted 1188 C++ 00:00.03 1340K */
             2 #include <string>
             3 #include <iostream>
             4 
             5 using namespace std;
             6 
             7 int main()
             8 {
             9     int N;
            10     cin >> N;
            11     
            12     while(N--)
            13     {
            14         int n, m;
            15         cin >> m >> n;
            16         
            17         string s[100];
            18         for(int i = 0; i < n; i++)
            19             cin >> s[i];
            20         
            21         int max = 0;
            22         int cnt[1250][101= {0};
            23         for(int k = 0; k < n; k++)
            24         {
            25             int sum = 0;
            26             for(int i = 0; i < m; i++)
            27                 for(int j = i + 1; j < m; j++)
            28                     if(s[k][i] > s[k][j])
            29                         sum++;
            30             max >?= sum;
            31             cnt[sum][0]++;
            32             cnt[sum][cnt[sum][0]] = k;
            33         }
            34         
            35         for(int i = 0; i <= max; i++)
            36             if(cnt[i][0])
            37                 for(int j = 1; j <= cnt[i][0]; j++)
            38                     cout << s[cnt[i][j]] << endl;
            39         
            40         if(N)
            41             cout << endl;
            42     }
            43     
            44     return 0;
            45 }
            46 

            posted @ 2008-04-13 09:11 superman 閱讀(285) | 評(píng)論 (0)編輯 收藏

             1 /* Accepted 1159 C++ 00:04.20 3584K */
             2 #include <stdio.h>
             3 #include <ctype.h>
             4 #include <string.h>
             5 #include <stdlib.h>
             6 
             7 struct string
             8 {
             9     int size;
            10     char str[10];
            11     
            12     string() { size = 0; }
            13     void clear() { size = 0; }
            14     void operator += (const char & c)
            15     {
            16         str[size] = c;
            17         size++;
            18     }
            19     bool operator == (const string & s)
            20     {
            21         return strcmp(str, s.str) == 0;
            22     }
            23 }s[100000];
            24 
            25 int cmp(const void * a, const void * b)
            26 {
            27     string * c = (string *) a;
            28     string * d = (string *) b;
            29     return strcmp(c -> str, d -> str);
            30 }
            31 
            32 int main()
            33 {
            34     int N;
            35     scanf("%d"&N);
            36     
            37     char cur[1000], letter2digit[] = "2223334445556667-77888999-";
            38     
            39     while(N--)
            40     {
            41         int n;
            42         scanf("%d"&n);
            43         for(int i = 0; i < n; i++)
            44         {
            45             s[i].clear();
            46             scanf("%s", cur);
            47             for(int j = 0; j < strlen(cur); j++)
            48             {
            49                 if(s[i].size == 3)
            50                     s[i] += '-';
            51                 if(cur[j] == '-')
            52                     continue;
            53                 if(isdigit(cur[j]))
            54                 {
            55                     s[i] += cur[j];
            56                     continue;
            57                 }
            58                 s[i] += letter2digit[cur[j] - 'A'];
            59             }
            60         }
            61         
            62         qsort(s, n, sizeof(string), cmp);
            63         
            64         int i = 0, cnt = 0;
            65         while(i < n)
            66         {
            67             int j = i + 1;
            68             while(j < n && s[i] == s[j])
            69                 j++;
            70             
            71             if(j - i > 1)
            72             {
            73                 cnt++;
            74                 printf("%s %d\n", s[i].str, j - i);
            75             }
            76             
            77             i = j;
            78         }
            79         if(cnt == 0)
            80             printf("No duplicates.\n");
            81         
            82         if(N)
            83             putchar('\n');
            84     }
            85     
            86     return 0;
            87 }
            88 

            posted @ 2008-04-12 21:44 superman 閱讀(283) | 評(píng)論 (0)編輯 收藏

            I can't stand the problem.
            TLE many times just because of using cin/cout :(
             1 /* Accepted 1168 C++ 00:00.21 472K */
             2 #include <stdio.h>
             3 
             4 int f[21][21][21];
             5 int w(int a, int b, int c)
             6 {
             7     if(a <= 0 || b <= 0 || c <= 0)
             8         return 1;
             9     
            10     if(f[a][b][c])
            11         return f[a][b][c];    
            12     
            13     if(a < b && b < c)
            14         return f[a][b][c] = w(a, b, c-1+ w(a, b-1, c-1- w(a, b-1, c);
            15     return f[a][b][c] = w(a-1, b, c) + w(a-1, b-1, c) + w(a-1, b, c-1- w(a-1, b-1, c-1);
            16 }
            17 
            18 int main()
            19 {
            20     int a, b, c;
            21     while(scanf("%d %d %d"&a, &b, &c) != EOF)
            22     {
            23         if(a == -1 && b == -1 && c == -1)
            24             break;
            25         
            26         printf("w(%d, %d, %d) = ", a, b, c);
            27         if(a <= 0 || b <= 0 || c <= 0)
            28             printf("1\n");
            29         else
            30         {
            31             if(a > 20 || b > 20 || c > 20)
            32                 a = 20, b = 20, c = 20;
            33             printf("%d\n", w(a, b, c));
            34         }
            35     }
            36     
            37     return 0;
            38 }
            39 

            posted @ 2008-04-11 18:46 superman 閱讀(396) | 評(píng)論 (1)編輯 收藏

             1 /* Accepted 1117 C++ 00:00.00 840K */
             2 #include <string>
             3 #include <limits.h>
             4 #include <iostream>
             5 
             6 using namespace std;
             7 
             8 int cnt[27], len, ans;
             9 
            10 struct
            11 {
            12     int w;
            13     int left, right;
            14     bool used;
            15 }Tree[100];
            16 
            17 void InOrder(int p, int n)
            18 {
            19     if(Tree[p].left)
            20         InOrder(Tree[p].left, n + 1);
            21     if(Tree[p].right)
            22         InOrder(Tree[p].right, n + 1);
            23     if(Tree[p].left == 0 && Tree[p].right == 0)
            24         ans += Tree[p].w * n;
            25 }
            26 
            27 int main()
            28 {
            29     cout.setf(ios_base::showpoint);
            30     cout.setf(ios_base::fixed);
            31     cout.precision(1);
            32     
            33     string s;
            34     while(cin >> s && s != "END")
            35     {
            36         memset(cnt, 0sizeof(cnt));
            37         for(int i = 0; i < s.size(); i++)
            38             if(s[i] == '_')
            39                 cnt[0]++;
            40             else
            41                 cnt[s[i] - 'A' + 1]++;
            42         
            43         len = 0;
            44         for(int i = 0; i < 27; i++)
            45             if(cnt[i])
            46             {
            47                 len++;
            48                 Tree[len].w = cnt[i];
            49                 Tree[len].left = Tree[len].right = 0;
            50                 Tree[len].used = false;
            51             }
            52         
            53         while(true)
            54         {
            55             int m1 = INT_MAX, m2 = INT_MAX, idx1, idx2;
            56             
            57             for(int i = 1; i <= len; i++)
            58                 if(Tree[i].used == false)
            59                     if(m1 > Tree[i].w)
            60                     {
            61                         m1 = Tree[i].w;
            62                         idx1 = i;
            63                     }
            64             if(m1 == INT_MAX) break;
            65             Tree[idx1].used = true;
            66             
            67             for(int i = 1; i <= len; i++)
            68                 if(Tree[i].used == false)
            69                     if(m2 > Tree[i].w)
            70                     {
            71                         m2 = Tree[i].w;
            72                         idx2 = i;
            73                     }
            74             if(m2 == INT_MAX) break;
            75             Tree[idx2].used = true;
            76 
            77             len++;
            78             Tree[len].w = m1 + m2;
            79             Tree[len].left = idx1;
            80             Tree[len].right = idx2;
            81             Tree[len].used = false;
            82         }
            83         
            84         if(len == 1)
            85             ans = s.size();
            86         else
            87         {
            88             ans = 0;
            89             InOrder(len, 0);
            90         }
            91         
            92         cout << 8 * s.size() << ' ' << ans << ' '
            93              << double(8 * s.size()) / ans << endl;
            94     }
            95     
            96     return 0;
            97 }
            98 

            posted @ 2008-04-11 17:00 superman 閱讀(286) | 評(píng)論 (0)編輯 收藏

             1 /* Accepted 1154 C++ 00:00.24 844K */
             2 #include <string>
             3 #include <iostream>
             4 
             5 using namespace std;
             6 
             7 int main()
             8 {
             9     int N;
            10     cin >> N;
            11     while(N--)
            12     {
            13         string n; int base;
            14         while((cin >> base&& base)
            15         {
            16             cin >> n;
            17             
            18             int sum = 0, m = 0;
            19             for(int i = 0; i < n.size(); i++)
            20             {
            21                 sum += n[i] - '0';
            22                 m = m * base + n[i] - '0';
            23             }
            24             
            25             cout << (m % sum == 0 ? "yes" : "no"<< endl;
            26         }
            27         if(N)
            28             cout << endl;
            29     }
            30     
            31     return 0;
            32 }
            33 

            posted @ 2008-04-11 09:57 superman 閱讀(535) | 評(píng)論 (0)編輯 收藏

             1 /* Accepted 1179 C++ 00:00.00 848K */
             2 #include <string>
             3 #include <stdlib.h>
             4 #include <iostream>
             5 #include <algorithm>
             6 
             7 using namespace std;
             8 
             9 struct point { int x, y; char letter; } p[26];
            10 
            11 int cmp(const void * a, const void * b)
            12 {
            13     point * c = (point *) a;
            14     point * d = (point *) b;
            15     if(c -> x == d -> x)
            16         return c -> y - d -> y;
            17     return  c -> x - d -> x;
            18 }
            19 
            20 int main()
            21 {
            22     int n, set = 0;
            23     while((cin >> n) && n)
            24     {
            25         for(int i = 0; i < n; i++)
            26             cin >> p[i].letter >> p[i].x >> p[i].y;
            27         
            28         qsort(p, n, sizeof(point), cmp);
            29         
            30         string rec[1000]; int m = 0;
            31         for(int i = 0; i < n; i++)
            32             for(int j = i + 1; j < n; j++)
            33             {
            34                 int a = -1, b = -1;
            35                 for(int k = i + 1; k < n; k++)
            36                     if(p[k].x == p[i].x && p[k].y == p[j].y)
            37                     {
            38                         a = k;
            39                         break;
            40                     }
            41                 for(int k = i + 1; k < n; k++)
            42                     if(p[k].x == p[j].x && p[k].y == p[i].y)
            43                     {
            44                         b = k;
            45                         break;
            46                     }
            47                 if(a != -1 && b != -1)
            48                 {
            49                     rec[m] += p[a].letter;
            50                     rec[m] += p[j].letter;
            51                     rec[m] += p[b].letter;
            52                     rec[m] += p[i].letter;
            53                     m++;
            54                 }
            55             }
            56         sort(rec, rec + m);
            57         
            58         cout << "Point set " << ++set << ':';
            59         if(m == 0)
            60             cout << " No rectangles";
            61         else
            62         {
            63             cout << endl;
            64             for(int i = 0; i < m; i++)
            65             {
            66                 cout << ' ' << rec[i];
            67                 if(i + 1 != m && (i + 1% 10 == 0)
            68                     cout << endl;
            69             }
            70         }
            71         cout << endl;
            72     }
            73     
            74     return 0;
            75 }
            76 

            posted @ 2008-04-10 23:00 superman 閱讀(273) | 評(píng)論 (0)編輯 收藏

             1 /* Accepted 1134 C++ 00:07.71 9716K */
             2 #include <stdio.h>
             3 #include <iostream>
             4 
             5 using namespace std;
             6 const int N = 1500;
             7 
             8 struct { int cnt, son[1500]; } Tree[1500];
             9 
            10 int f[1500][2];
            11 void PostOrder(int p)
            12 {
            13     if(Tree[p].cnt == 0)
            14     {
            15         f[p][0= 0;
            16         f[p][1= 1;
            17         return;
            18     }
            19     for(int i = 0; i < Tree[p].cnt; i++)
            20         PostOrder(Tree[p].son[i]);
            21     
            22     f[p][1]++;
            23     for(int i = 0; i < Tree[p].cnt; i++)
            24     {
            25         f[p][0+= f[Tree[p].son[i]][1];
            26         f[p][1+= min(f[Tree[p].son[i]][0], f[Tree[p].son[i]][1]);
            27     }
            28 }
            29 
            30 int main()
            31 {
            32     int n;
            33     while(cin >> n)
            34     {
            35         memset(Tree, 0sizeof(Tree));
            36         memset(f, 0sizeof(f));
            37         
            38         int s, m = 0;
            39         bool x[1500= {false};
            40         for(int i = 0; i < n; i++)
            41         {
            42             scanf("%d:(%d)"&s, &m);
            43             for(int i = 0; i < m; i++)
            44             {
            45                 Tree[s].cnt = m;
            46                 cin >> Tree[s].son[i];
            47                 x[Tree[s].son[i]] = true;
            48             }
            49         }
            50         int root;
            51         for(int i = 0; i < n; i++)
            52             if(x[i] == false)
            53             {
            54                 root = i;
            55                 break;
            56             }
            57         
            58         PostOrder(root);
            59         
            60         cout << min(f[root][0], f[root][1]) << endl;
            61     }
            62     
            63     return 0;
            64 }
            65 

            posted @ 2008-04-10 18:18 superman 閱讀(310) | 評(píng)論 (0)編輯 收藏

              1 /* Accepted 1197 C++ 00:00.00 836K */
              2 #include <iostream>
              3 
              4 using namespace std;
              5 
              6 struct { int x1, y1, x2, y2, match; } slide[26];
              7 struct { int x, y; bool matched; } p[26];
              8 
              9 int n;
             10 
             11 bool s1()
             12 {
             13     for(int i = 0; i < n; i++)
             14         if(slide[i].match == -1)
             15         {
             16             int cnt = 0, idx;
             17             for(int j = 0; j < n; j++)
             18                 if(p[j].matched == false)
             19                     if(slide[i].x1 <= p[j].x && p[j].x <= slide[i].x2)
             20                     if(slide[i].y1 <= p[j].y && p[j].y <= slide[i].y2)
             21                     {
             22                         cnt++;
             23                         idx = j;
             24                         if(cnt > 1)
             25                             break;
             26                     }
             27             if(cnt == 1)
             28             {
             29                 slide[i].match = idx;
             30                 p[idx].matched = true;
             31                 return true;
             32             }
             33         }
             34     return false;
             35 }
             36 
             37 bool s2()
             38 {
             39     for(int i = 0; i < n; i++)
             40         if(p[i].matched == false)
             41         {
             42             int cnt = 0, idx;
             43             for(int j = 0; j < n; j++)
             44                 if(slide[j].match == -1)
             45                     if(slide[j].x1 <= p[i].x && p[i].x <= slide[j].x2)
             46                     if(slide[j].y1 <= p[i].y && p[i].y <= slide[j].y2)
             47                     {
             48                         cnt++;
             49                         idx = j;
             50                         if(cnt > 1)
             51                             break;
             52                     }
             53             if(cnt == 1)
             54             {
             55                 p[i].matched = true;
             56                 slide[idx].match = i;
             57                 return true;
             58             }
             59         }
             60     return false;
             61 }
             62 
             63 int main()
             64 {
             65     int Heap = 0;
             66     while((cin >> n) && n)
             67     {
             68         for(int i = 0; i < n; i++)
             69         {
             70             slide[i].match = -1;
             71             cin >> slide[i].x1 >> slide[i].x2 >> slide[i].y1 >> slide[i].y2;
             72         }
             73         for(int i = 0; i < n; i++)
             74         {
             75             p[i].matched = false;
             76             cin >> p[i].x >> p[i].y;
             77         }
             78         
             79         int m = 0;
             80         while(s1())m++;
             81         while(s2())m++;
             82         
             83         cout << "Heap " << ++Heap << endl;
             84         
             85         if(m == 0)
             86             cout << "none" << endl;
             87         else
             88         {
             89             while(m)
             90                 for(int i = 0; i < n; i++)
             91                     if(slide[i].match != -1)
             92                     {
             93                         cout << '(' << char(i + 'A'<< ',' << slide[i].match + 1 << ')';
             94                         cout << (--== 0 ? '\n' : ' ');
             95                     }
             96         }
             97         cout << endl;
             98     }
             99     
            100     return 0;
            101 }
            102 

            posted @ 2008-04-09 19:52 superman 閱讀(422) | 評(píng)論 (0)編輯 收藏

            僅列出標(biāo)題
            共19頁(yè): First 10 11 12 13 14 15 16 17 18 Last 
            久久精品成人一区二区三区| 一本久道久久综合狠狠爱| 久久久午夜精品福利内容| 久久精品国产亚洲AV无码麻豆 | 色综合久久久久无码专区| 国产精品久久99| 婷婷久久综合| 久久99精品久久久久婷婷| 色综合久久88色综合天天 | 男女久久久国产一区二区三区| 777久久精品一区二区三区无码| 伊人色综合九久久天天蜜桃| 97久久精品午夜一区二区| 久久亚洲欧洲国产综合| www性久久久com| 久久久久久久91精品免费观看| 久久99精品国产99久久| 欧美日韩精品久久久免费观看| 99久久精品费精品国产| 亚洲国产精品无码久久久不卡 | 一级A毛片免费观看久久精品| 国产婷婷成人久久Av免费高清| 久久久久亚洲精品无码网址| 97精品伊人久久大香线蕉app| 亚洲欧美日韩精品久久亚洲区 | 99久久婷婷免费国产综合精品| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 亚洲国产天堂久久久久久| 精品国产福利久久久| 亚洲欧美伊人久久综合一区二区| 亚洲午夜久久影院| 国产美女久久精品香蕉69| 国产亚洲美女精品久久久2020| 久久久久国产精品麻豆AR影院| MM131亚洲国产美女久久| 亚洲综合伊人久久综合| 中文字幕久久精品 | 久久无码人妻精品一区二区三区 | 精品人妻久久久久久888| 久久伊人精品一区二区三区| 久久久久一级精品亚洲国产成人综合AV区 |