首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

noip2012 阅读程序三

2012-10-17 
noip2012 阅读程序3#includecstdio#includecstring#includemath.h#includestdlib.h#includealgor

noip2012 阅读程序3

#include<cstdio>#include<cstring>#include<math.h>#include<stdlib.h>#include<algorithm>#include<ctime>#include<iostream>using namespace std;const int SIZE=20;int data[SIZE];int n,i,h,ans;void merge(){data[h-1]+=data[h];h--;ans++;}int main(){#ifndef ONLINE_JUDGE  freopen("in1.txt","r",stdin);#endifint i,j;cin>>n;h=1;data[h]=1;ans=0;for(i=2;i<=n;i++){h++;data[h]=1;while(h>1&& data[h]==data[h-1]) merge();}cout<<ans<<endl;//printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);  return 0;}/**/

热点排行