青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

worm

為什么我的眼里飽含淚水?因為我程序沒寫完!
隨筆 - 5, 文章 - 2, 評論 - 10, 引用 - 0
數據加載中……

2009年3月8日

poj 3414解題報告(廣搜題)

     摘要:                 郁悶那,寫了七個小時,一直在調試錯誤了!fuck it! 這個與別的BFS題的主要不同是要記錄正確順序的路徑,我用path[i][j] = {way,a,b}表示狀態(i,j)是由狀態(a,b)經過方式way(一共六種...  閱讀全文

posted @ 2009-03-08 18:40 WORM 閱讀(1676) | 評論 (5)編輯 收藏

poj 3191解題報告

The Moronic Cowmpouter
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 1344 Accepted: 676

Description

Inexperienced in the digital arts, the cows tried to build a calculating engine (yes, it's a cowmpouter) using binary numbers (base 2) but instead built one based on base negative 2! They were quite pleased since numbers expressed in base −2 do not have a sign bit.

You know number bases have place values that start at 1 (base to the 0 power) and proceed right-to-left to base^1, base^2, and so on. In base −2, the place values are 1, −2, 4, −8, 16, −32, ... (reading from right to left). Thus, counting from 1 goes like this: 1, 110, 111, 100, 101, 11010, 11011, 11000, 11001, and so on.

Eerily, negative numbers are also represented with 1's and 0's but no sign. Consider counting from −1 downward: 11, 10, 1101, 1100, 1111, and so on.

Please help the cows convert ordinary decimal integers (range -2,000,000,000..2,000,000,000) to their counterpart representation in base −2.

Input

Line 1: A single integer to be converted to base −2

Output

Line 1: A single integer with no leading zeroes that is the input integer converted to base −2. The value 0 is expressed as 0, with exactly one 0.

Sample Input

-13

Sample Output

110111

Hint

Explanation of the sample:

Reading from right-to-left:
1*1 + 1*-2 + 1*4 + 0*-8 +1*16 + 1*-32 = -13
 題目的意思就是讓你把一個數轉換為-2進制,
基本原理:
               如果n為奇數,那么末位肯定為1,因此就可以轉為求(x-1)/-2 的子問題了! (除以-2可以類比十進制就能理解了)
               如果n為偶數,末位必為0,然后再轉為求x/-2的子問題;
結束條件當 n=1。
思路很簡單,但是有兩個小方面要提提,一定要考慮n=0的情況,我就是沒考慮而一直超時,郁悶,還找不出錯誤,陷入了死循環怪不得超時,還有注意球的結果是逆序的!!呵呵下面是代碼:
 1//============================================================================
 2// Name        : poj 3191.cpp
 3// Author      : worm
 4// Copyright   : Your copyright notice
 5// Description :把一個十進制的數轉換為-2進制的數
 6//============================================================================
 7
 8#include <iostream>
 9#include <stdio.h>
10#include <string>
11#include <math.h>
12using namespace std;
13string a= "";
14int main() {
15    int x;
16    cin >> x;
17    if (x == 0{
18        cout <<"0"<<endl;
19        return 0;
20    }

21
22    while (x != 1{
23        if (abs(x) % 2 == 1{
24            a += '1';
25            x = (x-1)/-2;
26            continue;
27        }

28        a += '0';
29        x /= -2;
30    }

31    cout <<"1";
32    for (int i = a.length() - 1; i >= 0; i--{
33        printf("%c",a[i]);
34    }

35
36    return 0;
37}

38

posted @ 2009-03-08 12:37 WORM 閱讀(1174) | 評論 (1)編輯 收藏

poj 3126 Prim Path 第一道BFS

      對于一個四位數,對于它某一位變化之后的素數,即“相鄰的素數”,進行廣度搜索,知道搜索到為止!
挺簡單,看代碼應該可以看懂,下面是代碼
9#include <iostream>
10#include <queue>
11#include <math.h>
12using namespace std;
13int a, b;
14int p[9999= 0 };
15int visited[9999= 0 };
16bool isprime(int x) {
17
18    for (int i = 2; i <= sqrt((double) x); ++i) {
19        if (x % i == 0)
20            return false;
21    }

22    return true;
23}

24int BFS(int s, int r) {
25    queue<int> q;
26    q.push(s);
27    p[s] = 0;
28    visited[s] = 1;
29    while (!q.empty()) {
30        int temp = q.front();
31        q.pop();
32        for (int i = 0; i <= 9; i++{
33            int y1 = (temp / 10* 10 + i;
34            if (isprime(y1) && !visited[y1]) {
35                q.push(y1);
36                p[y1] = p[temp] + 1;
37                visited[y1] = 1;
38            }

39            int y2 = temp % 10 + (temp / 100* 100 + i * 10;
40            if (isprime(y2) && !visited[y2]) {
41                q.push(y2);
42                p[y2] = p[temp] + 1;
43                visited[y2] = 1;
44            }

45            int y3 = temp % 100 + (temp / 1000* 1000 + 100 * i;
46            if (isprime(y3) && !visited[y3]) {
47                q.push(y3);
48                p[y3] = p[temp] + 1;
49                visited[y3] = 1;
50            }

51            if (i != 0{
52                int y4 = temp % 1000 + i * 1000;
53                if (isprime(y4) && !visited[y4]) {
54                    q.push(y4);
55                    p[y4] = p[temp] + 1;
56                    visited[y4] = 1;
57                }

58            }

59            if (visited[r])
60                return p[r];
61        }

62
63    }

64    return 0;
65}

66int main() {
67    int n;
68    cin >> n;
69    while (n--{
70        memset(visited,0,sizeof(visited));
71        memset(p,0,sizeof(p));
72        cin >> a >> b;
73        cout << BFS(a, b) << endl;
74
75    }

76    return 0;
77}

78

posted @ 2009-03-08 10:36 WORM 閱讀(1349) | 評論 (1)編輯 收藏

2009年3月7日

第一道廣度搜索BFS紀念 poj 3278 源代碼

   參考了別人的思路,做出了第一道BFS,雖然在大牛們看來不屑一顧,but about me,I really happy for it, I'm coming ! worm never give up!!
 1//============================================================================
 2// Name        : poj.cpp
 3// Author      :
 4// Version     :
 5// Copyright   : Your copyright notice
 6// Description : Hello World in C++, Ansi-style
 7//============================================================================
 8
 9#include <iostream>
10#include <queue>
11using namespace std;
12queue<int> q;
13int    result[100001];
14int visited[100001= {0};
15int BFS(int start,int end) {
16    if (start == end)
17        return 0;
18    q.push(start);
19    result[start] = 0;
20    visited[start] = 1;
21    while(!q.empty()) {
22        int temp = q.front();
23        q.pop();
24        int next;
25        for (int i = 0; i < 3++i) {
26            if (i == 0)
27                next = temp - 1;
28            if (i == 1)
29                next = temp + 1;
30            if (i == 2)
31                next = temp*2;
32            if(next > 100000 || next < 0{
33                continue;
34            }

35            if (visited[next] != 1{
36                q.push(next);
37                result[next] = result[temp] + 1;
38                visited[next] = 1;
39            }

40            if (next == end)
41                return result[next];
42        }

43    }

44    return 0;
45}

46int main() {
47    int n,k;
48    cin >> n >> k;
49    cout << BFS(n,k) << endl;
50    return 0;
51}

52

posted @ 2009-03-07 18:31 WORM 閱讀(1316) | 評論 (3)編輯 收藏

2009年3月6日

poj 3705解題思路及源代碼

 1//============================================================================
 2// Name        : poj.cpp
 3// Author      :
 4// Version     :
 5// Copyright   : Your copyright notice
 6// Description : 題目大意就是將正序數列1,2,3,,n,通過最少的“復制粘貼”數
 7// 變為逆序序列的問題。
 8//基本思想:  如果n為奇數,假設n = 7;
 9// 1 2 3 4 5 6 7          將n左邊的最中間的兩個數依次移到7的右邊
10// 1 2 5 6 7 3 4       的最中間
11// 1 6 7 3 2 5 4
12// 7 3 2 1 6 5 4          將 3 2 1與 6 5 4 交換
13// 7 6 5 4 3 2 1
14//總的次數為(n+1)/2;
15// n =  偶數時,可以先把n不管,這樣n-1就為奇數的情況,求出后的序列在和n交換一下
16//即可,結果為n/2 + 1;
17//============================================================================
18
19#include <iostream>
20using namespace std;
21void solve(int n) {
22    int x = (n+1)/2 - 1;
23    int y = n;
24    for (int i = 0; i < x; ++i) {
25        cout << n/2 << " " << 2 << " " << y-2-<< endl;
26        n -= 2;
27    }

28    cout <<"" << x << " " << x + 1 << endl;
29}

30
31int main() {
32    int n;
33    cin >> n;
34    if (n == 1{
35        cout << 0 <<endl;
36        return 0;
37    }

38    if (n == 2{
39        cout << "1" <<endl;
40        cout << "1 1 1" <<endl;
41        return 0;
42    }

43    if (n % 2 != 0{
44        cout << (n+1)/2 <<endl;
45         solve(n);
46    }

47    else {
48        cout << n/2 + 1 << endl;
49        solve(n-1);
50        cout << 1 << " "<< n-1 <<" 1" <<endl;
51    }

52
53    return 0;
54}

55

最后一定要注意1 和 2 的情況,我因為忘了考慮,wa了幾次,呵呵...

posted @ 2009-03-06 08:52 WORM 閱讀(324) | 評論 (0)編輯 收藏

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美一区二区日韩一区二区| 国产欧美精品在线播放| 在线观看精品一区| 久久久无码精品亚洲日韩按摩| 亚洲性视频网站| 国产精品日韩| 久久精品一本| 久久综合伊人77777蜜臀| 在线播放一区| 99re6热在线精品视频播放速度| 蜜臀av一级做a爰片久久| 亚洲啪啪91| 一区二区三区成人精品| 亚洲人成欧美中文字幕| 欧美成人免费网站| 亚洲午夜激情| 亚洲欧美一区二区激情| 在线观看一区二区视频| 日韩午夜在线电影| 国语精品一区| 日韩午夜精品视频| 国产精品久久久久aaaa| 巨乳诱惑日韩免费av| 欧美成人亚洲| 欧美资源在线| 欧美久久综合| 久久久av网站| 欧美激情精品| 久久国产精品99国产精| 欧美成人影音| 久久精品国亚洲| 欧美成在线观看| 欧美一区二区在线免费播放| 亚洲视频欧美视频| 精品动漫一区| 亚洲综合激情| 亚洲手机在线| 麻豆成人在线| 久久精品夜色噜噜亚洲a∨| 欧美精品七区| 欧美h视频在线| 国产精品美女午夜av| 9色精品在线| 美女图片一区二区| 亚洲综合欧美日韩| 久久免费少妇高潮久久精品99| 亚洲欧美日韩国产成人| 欧美激情视频一区二区三区免费 | 精品成人a区在线观看| 亚洲狼人精品一区二区三区| 亚洲成色777777在线观看影院| 99视频一区| 在线视频你懂得一区| 欧美成人精品激情在线观看| 久久在线精品| 伊人久久亚洲美女图片| 99视频日韩| 国产精品99久久久久久久久| 欧美激情区在线播放| 亚洲国产婷婷香蕉久久久久久| 影音先锋久久| 久久综合色播五月| 欧美国产亚洲精品久久久8v| 激情久久久久久久| 久久精品2019中文字幕| 久久gogo国模裸体人体| 国产欧美视频一区二区| 午夜久久资源| 欧美一区二区免费| 国产伦精品一区二区三区四区免费 | 日韩视频中文字幕| 亚洲一区二区三区久久| 欧美先锋影音| 欧美三级视频在线| 亚洲精品在线免费观看视频| 亚洲午夜av在线| 国产精品色在线| 久久福利毛片| 亚洲第一天堂av| aa级大片欧美| 国产精品视频久久一区| 欧美一区二区在线播放| 久久综合国产精品| 亚洲欧洲日夜超级视频| 欧美日韩成人在线播放| 一区二区三区欧美成人| 久久国产精品久久w女人spa| 精品999网站| 欧美日本不卡高清| 亚洲综合精品自拍| 免费成人小视频| 亚洲视频网站在线观看| 国产欧美一区二区三区久久| 久久美女性网| 99精品国产99久久久久久福利| 欧美一区二区高清| 国产亚洲欧美日韩在线一区| 另类综合日韩欧美亚洲| 一本在线高清不卡dvd| 久久久午夜精品| 这里只有精品丝袜| 国内精品免费午夜毛片| 欧美极品aⅴ影院| 午夜精品福利在线观看| 欧美激情在线观看| 久久成人国产| 一区二区成人精品| 一区二区三区在线观看国产| 国产精品成人一区二区| 另类天堂av| 羞羞漫画18久久大片| 亚洲人成小说网站色在线| 欧美影院久久久| 一区二区三区国产精华| 亚洲成色最大综合在线| 国产亚洲精品综合一区91| 欧美激情中文字幕一区二区| 久久国产欧美| 性8sex亚洲区入口| 一本一本久久a久久精品综合妖精| 美女任你摸久久| 久久久久久97三级| 欧美一级理论片| 亚洲资源av| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 亚洲午夜羞羞片| 亚洲精品日产精品乱码不卡| 另类图片国产| 久久久无码精品亚洲日韩按摩| 午夜综合激情| 午夜精品福利一区二区三区av| aaa亚洲精品一二三区| 亚洲国产你懂的| 在线欧美一区| 亚洲高清激情| 亚洲国产成人午夜在线一区| 国产日韩一区二区三区在线| 国产精品捆绑调教| 国产精品五月天| 国产精品午夜视频| 欧美三级特黄| 国产精品v欧美精品v日本精品动漫| 欧美日韩精品福利| 欧美日韩另类一区| 欧美阿v一级看视频| 你懂的亚洲视频| 欧美电影免费观看大全| 欧美国产免费| 亚洲国产小视频在线观看| 亚洲福利视频一区二区| 亚洲国产成人午夜在线一区| 亚洲第一精品夜夜躁人人爽| 欧美激情网站在线观看| 91久久国产综合久久| 最新国产の精品合集bt伙计| 亚洲精品中文字幕有码专区| 夜夜精品视频一区二区| 亚洲欧美精品一区| 久久久久久免费| 能在线观看的日韩av| 欧美精品videossex性护士| 欧美日韩午夜| 国产亚洲观看| 亚洲九九精品| 香蕉免费一区二区三区在线观看| 久久国产欧美精品| 欧美国产精品人人做人人爱| 亚洲人成啪啪网站| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 欧美成人久久| 亚洲精选大片| 久久国产乱子精品免费女| 蜜臀va亚洲va欧美va天堂| 欧美日韩一区二区三区在线观看免 | 欧美精品aa| 国产一区在线免费观看| 亚洲精品日韩一| 午夜精品久久久久久99热| 久久这里有精品15一区二区三区| 亚洲国产小视频| 欧美影片第一页| 欧美人在线视频| 揄拍成人国产精品视频| 亚洲一区二区三区影院| 麻豆av一区二区三区| 99视频热这里只有精品免费| 久久久五月婷婷| 国产欧美高清| 亚洲影院免费| 欧美激情一区二区三区在线视频观看| 一区二区欧美精品| 免费久久99精品国产| 国产一区亚洲一区| 亚洲欧美在线x视频| 91久久夜色精品国产九色| 久久精品国产久精国产一老狼| 国产精品久久久久久久午夜片| 亚洲国产精品日韩| 久久亚洲一区二区三区四区| 亚洲私人影院|