Untitled

mail@pastecode.io avatar
unknown
c_cpp
a month ago
961 B
3
Indexable
Never
// in god we trust :)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int maxn = 45;
const int maxn2 = 5e5 + 7;
const int inf  = 1e9 + 7;
const ll mod = 1e9+7;
const int lg = 20;

void dbg(){
     cerr << endl;
}

template<typename H, typename... T> void dbg(H h, T... t){
     cerr << h << ", ";
     dbg(t...);
}

#define er(...) cerr << __LINE__ << " <" << #__VA_ARGS__ << ">: ", dbg(__VA_ARGS__)

void solve(){
	string s;
	s += "2";
	int car;
	for(int i = 2 ; i <= 1000 ; i++){
		car = 0;
		for(int j = s.length()-1 ; j >= 0 ; j--){
			int n = int(s[j]) - '0';
			n *= 2;
			n += car;
			//er(n);
			car = n/10 % 10;// 1 
			s[j] = char((n % 10) + '0');
		}
		reverse(s.begin() , s.end());
		if(car != 0)
			s += char(car + '0');
		reverse(s.begin() , s.end());
	}
	int sum = 0;
	for(int i = 0 ; i < s.length() ; i++){
		sum += int(s[i]) - '0';
	}
	cout << sum;
}
int main(){
	cin.tie(NULL) -> sync_with_stdio(NULL);
	solve();
}
Leave a Comment