64,641
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
const int MAX = 2008080808;
const int IT = 7;
template<int n, int curr, int last, int base, int weight>
class A
{
enum{it = n/base%10};
public:
enum{result = A<n, (it-(it>IT))* weight+((it<IT)?curr:(it==IT?last:base+curr)), last+base*it, base*10, (weight?weight*9+base:1)> :: result};
};
template<int n, int curr, int base, int weight>
class A<n, curr, n, base, weight>
{
public:
enum {result = curr};
};
int main(int argc, char* argv[])
{
cout << A<MAX+1, 0, 0, 1, 0>:: result << endl;
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n = 2*(pow(10.0,9) - pow(9.0,9)) + 7*(pow(10.0,6) - pow(9.0,6) +
pow(10.0,4) - pow(9.0,4) + 19) + 1000000 + 10000 + 100 +1;
cout<<n<<endl;
system("PAUSE");
return 0;
}