Submission #20908056


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	int comma = 0;
	ll ans = 0;
	ll L = 1, R = 10;
	rep(i, 0, 16) {
		if (R <= N) ans += (R - L) * comma;
		else if(L <= N && N < R) ans += (N - L + 1) * comma;

		L *= 10;
		R *= 10;
		if (i % 3 == 2) comma++;
	}
	cout << ans << endl;
}





Submission Info

Submission Time
Task C - Comma
User hamayanhamayan
Language C++ (GCC 9.2.1)
Score 300
Code Size 1676 Byte
Status AC
Exec Time 6 ms
Memory 3672 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 6 ms 3516 KB
hand_02.txt AC 2 ms 3536 KB
hand_03.txt AC 2 ms 3536 KB
random_01.txt AC 2 ms 3672 KB
random_02.txt AC 2 ms 3588 KB
random_03.txt AC 2 ms 3472 KB
random_04.txt AC 2 ms 3536 KB
random_05.txt AC 2 ms 3472 KB
random_06.txt AC 2 ms 3540 KB
random_07.txt AC 3 ms 3540 KB
random_08.txt AC 2 ms 3616 KB
random_09.txt AC 2 ms 3488 KB
random_10.txt AC 2 ms 3532 KB
random_11.txt AC 3 ms 3528 KB
random_12.txt AC 3 ms 3540 KB
random_13.txt AC 2 ms 3604 KB
random_14.txt AC 2 ms 3560 KB
random_15.txt AC 3 ms 3616 KB
sample_01.txt AC 2 ms 3604 KB
sample_02.txt AC 2 ms 3476 KB