记录编号 |
123720 |
评测结果 |
AWWWWWWWWWWWWWWWW |
题目名称 |
[Ural 1396] 最大值2 |
最终得分 |
5 |
用户昵称 |
HouJikan |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
3.303 s |
提交时间 |
2014-09-28 19:33:16 |
内存使用 |
0.31 MiB |
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <ctime>
#include <iterator>
#include <functional>
#define pritnf printf
#define scafn scanf
#define For(i,j,k) for(int i=(j);i<=(k);(i)++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint;
const int INF=0x7ffffff;
//==============struct declaration==============
//==============var declaration=================
map <unsigned long long,unsigned long long>f;
unsigned long long ans,n;
//==============function declaration============
unsigned long long F(unsigned long long x);
//==============main code=======================
int main()
{
string FileName="Maximum";//程序名
string FloderName="COGS";//文件夹名
freopen((FileName+".in").c_str(),"r",stdin);
freopen((FileName+".out").c_str(),"w",stdout);
#ifdef DEBUG
system(("cp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\standard.cpp C:\\Users\\Administrator\\Desktop\\"+FloderName+"\\submit.txt").c_str());
clock_t Start_Time=clock();
#endif
ios::sync_with_stdio(false);
f.clear();
f[1]=1;f[0]=0;
while (cin>>n&&n){
if (n%2==0)
n--;
ans=F(n);
cout<<ans<<endl;
}
#ifdef DEBUG
clock_t End_Time=clock();
cout<<endl<<endl<<"Time Used: "<<double(End_Time-Start_Time)*1000/(CLOCKS_PER_SEC)<<" Ms"<<endl;
#endif
return 0;
}
//================fuction code====================
unsigned long long F(unsigned long long x)
{
unsigned long long t;
if (f[x]!=0)
return f[x];
if (x&1)
t= f[x]=F(x/2)+F(x/2+1);
if ((x&1)==0)
t=f[x]=F(x/2);
return t;
}