#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include//assert(); //#include //xAOJ ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; typedef unsigned long long ULL; ///////// using namespace::std; ///////// ///////// ULL popcount(ULL N){ ULL ret = N; ret = ((0xAAAAAAAAAAAAAAAA & ret)>> 1) + (0x5555555555555555 & ret); ret = ((0xCCCCCCCCCCCCCCCC & ret)>> 2) + (0x3333333333333333 & ret); ret = ((0xF0F0F0F0F0F0F0F0 & ret)>> 4) + (0x0F0F0F0F0F0F0F0F & ret); ret = ((0xFF00FF00FF00FF00 & ret)>> 8) + (0x00FF00FF00FF00FF & ret); ret = ((0xFFFF0000FFFF0000 & ret)>>16) + (0x0000FFFF0000FFFF & ret); ret = ((0xFFFFFFFF00000000 & ret)>>32) + (0x00000000FFFFFFFF & ret); return ret; } void to_num(vector& ans, string str,const int keta){ int len = str.length(); ans.resize(len/(keta-1)+1); string temp; ULL pow10 = 1; for(int i= 0;i num; int len; int ketaMax; ULL powMax; ULL dimNum; void set(string str){ ketaMax = 9; powMax = 1; to_num(num, str,ketaMax); len = numLen(); for(int i=0;i=0;--i){ if( num[i] != 0){ break; } } return i+1; } ULL div(){// ULL ans; ULL ama = 0; //dimNum,powMax int i= len - 1; ULL temp; temp = (num[i] ) / dimNum; ama = (num[i] ) % dimNum; num[i] = temp; --i; for(; i > 0;--i){//上の桁から temp = (num[i] + ama*powMax) / dimNum; ama = (num[i] + ama*powMax) % dimNum; num[i+1] += temp / powMax; num[i] = temp % powMax; } if(i==0){ temp = (num[i] + ama*powMax) / dimNum; ama = (num[i] + ama*powMax) % dimNum; num[i+1] += temp / powMax; num[i] = temp % powMax; } ans = popcount(ama); //////// if( num[len-1] == 0 ){ --len; } return ans; } void view(){ for(int i=len-1;i>=0;--i){ cout << num[i]; }cout << endl; } }; void solve(){ string str; cin >> str; vnum Num; Num.num.reserve(100000); Num.set(str); ULL count = 0; ULL test = 0; while(Num.len != 0){ count += Num.div(); //Num.view(); } cout << count%((ULL)1004535809) << endl; } int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(16);// solve(); return 0; }