pku 3705

#include<iostream>
#include
<stdio.h>
using namespace std;

void my_fun(int num,int time);
bool is_even(int num);
int main()
{
    
int num;
    
int time;
    
while(cin>>num)
    
{
        
if(num == 1)
        
{
            cout
<<0<<endl;
        }

        
else if(num == 2)
        
{
            cout
<<1<<endl;
            cout
<<"1 1 1"<<endl;
        }

        
else if(!is_even(num))
        
{
            cout
<<(time = (num+1)/2)<<endl;
            my_fun(num,time);
            cout
<<2<<" "<<(num-1)/2<<" "<<num - num/2<<endl;
        }

        
else
        
{
            cout
<<(time = (num + 1)/2 +1)<<endl;
            my_fun(num 
- 1,time-1);
            cout
<<2<<" "<<(num-2)/2<<" "<<num - num/2 <<endl;
            cout
<<num<<" "<<1<<" "<<0<<endl;
        }

    }

    
}

bool is_even(int num)
{
    
if(num % 2)
        
return false;
    
return true;
}

void my_fun(int num,int time)
{
    
int i;
    
int n = 0;
    
for(i = 0; i < time - 1++ i)
    
{
        cout
<<num/2<<" "<<2<<" ";
        cout
<<(num -= 2,num + n/2)<<endl;
        n 
+= 2;
    }

}

哎,这个程序是很久以来最狼狈的了,看看吧,笑话了~

posted on 2009-03-05 20:50 成大才子 阅读(184) 评论(1)  编辑 收藏 引用

评论

# re: pku 3705 2009-03-06 19:12 NightMare

你就是传说中的成大才子??
久仰久仰  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年3月>
252627282912
3456789
10111213141516
17181920212223
24252627282930
31123456

导航

统计

公告

关于更多关于成大才子,请访问http://hi.baidu.com/成大才子

常用链接

留言簿(1)

随笔档案

文章分类

文章档案

链接

搜索

最新评论

阅读排行榜

评论排行榜