Created
April 26, 2016 08:03
-
-
Save PreSoichiSumi/4c0a6c4538f44f44c13bdc831754c7c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#include <X11/Intrinsic.h> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
#define all(c) ((c).begin()), ((c).end()) | |
#define dump(c) cerr << "> " << #c << " = " << (c) << endl; | |
#define iter(c) __typeof((c).begin()) | |
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++) | |
#define REP(i, a, b) for (int i = a; i < (int)(b); i++) | |
#define rep(i, n) REP(i, 0, n) | |
#define mp make_pair | |
#define fst first | |
#define snd second | |
#define pb push_back | |
typedef unsigned int uint; | |
typedef long long ll; | |
typedef unsigned long long ull; | |
typedef vector<int> vi; | |
typedef vector<ll> vll; | |
typedef vector<vll> vvll; | |
typedef vector<vi> vvi; | |
typedef vector<double> vd; | |
typedef vector<vd> vvd; | |
typedef vector<string> vs; | |
typedef pair<int, int> pii; | |
typedef pair<ll, ll> pll; | |
const int INF = 1 << 29; | |
const double EPS = 1e-10; | |
template<class T> | |
bool chmax(T &a, const T &b) { | |
if (a < b) { | |
a = b; | |
return true; | |
} | |
return false; | |
} | |
template<class T> | |
bool chmin(T &a, const T &b) { | |
if (b < a) { | |
a = b; | |
return true; | |
} | |
return false; | |
} | |
template<class T> | |
ll stoi(T &str){ | |
ll ret; | |
stringstream ss; | |
ss << str; | |
ss >> ret; | |
return ret; | |
} | |
template<class T> | |
string toString(T i) { | |
stringstream ss; | |
ss << i; | |
return ss.str(); | |
} | |
struct prepare { | |
prepare() { | |
cout.setf(ios::fixed, ios::floatfield); | |
cout.precision(8); | |
ios_base::sync_with_stdio(false); | |
} | |
} _prepare; | |
ll getNumOb1Str(ll num){ | |
ll counter=0; | |
string str=toString(num); | |
for(int i=0;i<str.size();i++){ | |
if(str.at(i)=='1')counter++; | |
} | |
return counter; | |
} | |
template<class T> | |
T getNumOb1(T num){ | |
T counter=0; | |
for(T i=1;i<=num;i++){ | |
counter+=getNumOb1Str(i); | |
} | |
return counter; | |
} | |
int main() { | |
string s; | |
cin>>s; | |
ll i=stoi(s); | |
ll ans=getNumOb1(i); | |
cout<<ans<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment