Submission #60364878


Source Code Expand

#include<bits/stdc++.h>
#include"atcoder/all"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll inf=1ll<<61;
typedef modint1000000007 mi;

mi solve(ll X){
	mi ans=0;
	if(X==0)return ans;
	unsigned long long dgt=1;
	for(ll i=0;i<19;i++){
		if(X>=dgt*10){
			mi d=(i+1);
			d*=(11*dgt-1);
			d*=(9*dgt);
			d/=2;
			ans+=d;
		}
		else{
			mi d=(i+1);
			d*=(X+dgt);
			d*=(X-dgt+1);
			d/=2;
			ans+=d;
			return ans;
		}
		dgt*=10;
	}
	return ans;
}

int main(){
	ll L,R;cin>>L>>R;
	cout<<(solve(R)-solve(L-1)).val()<<endl;
}

Submission Info

Submission Time
Task 082 - Counting Numbers(★3)
User Rho17
Language C++ 20 (gcc 12.2)
Score 3
Code Size 736 Byte
Status AC
Exec Time 1 ms
Memory 3660 KiB

Compile Error

Main.cpp: In function ‘mi solve(ll)’:
Main.cpp:19:21: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘long long unsigned int’ [-Wsign-compare]
   19 |                 if(X>=dgt*10){
      |                    ~^~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 3 / 3
Status
AC × 4
AC × 39
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 03_large_01.txt, 03_large_02.txt, 03_large_03.txt, 03_large_04.txt, 03_large_05.txt, 04_wide_01.txt, 04_wide_02.txt, 04_wide_03.txt, 04_wide_04.txt, 04_wide_05.txt, 04_wide_06.txt, 04_wide_07.txt, 04_wide_08.txt, 04_wide_09.txt, 04_wide_10.txt, 05_border_01.txt, 05_border_02.txt, 05_border_03.txt, 05_border_04.txt, 05_border_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
01_random_01.txt AC 1 ms 3660 KiB
01_random_02.txt AC 1 ms 3452 KiB
01_random_03.txt AC 1 ms 3548 KiB
01_random_04.txt AC 1 ms 3448 KiB
01_random_05.txt AC 1 ms 3492 KiB
01_random_06.txt AC 1 ms 3408 KiB
01_random_07.txt AC 1 ms 3492 KiB
01_random_08.txt AC 1 ms 3660 KiB
01_random_09.txt AC 1 ms 3484 KiB
01_random_10.txt AC 1 ms 3384 KiB
02_small_01.txt AC 1 ms 3500 KiB
02_small_02.txt AC 1 ms 3448 KiB
02_small_03.txt AC 1 ms 3448 KiB
02_small_04.txt AC 1 ms 3408 KiB
02_small_05.txt AC 1 ms 3492 KiB
03_large_01.txt AC 1 ms 3472 KiB
03_large_02.txt AC 1 ms 3484 KiB
03_large_03.txt AC 1 ms 3660 KiB
03_large_04.txt AC 1 ms 3488 KiB
03_large_05.txt AC 1 ms 3484 KiB
04_wide_01.txt AC 1 ms 3548 KiB
04_wide_02.txt AC 1 ms 3484 KiB
04_wide_03.txt AC 1 ms 3464 KiB
04_wide_04.txt AC 1 ms 3524 KiB
04_wide_05.txt AC 1 ms 3584 KiB
04_wide_06.txt AC 1 ms 3456 KiB
04_wide_07.txt AC 1 ms 3500 KiB
04_wide_08.txt AC 1 ms 3448 KiB
04_wide_09.txt AC 1 ms 3476 KiB
04_wide_10.txt AC 1 ms 3556 KiB
05_border_01.txt AC 1 ms 3444 KiB
05_border_02.txt AC 1 ms 3476 KiB
05_border_03.txt AC 1 ms 3488 KiB
05_border_04.txt AC 1 ms 3488 KiB
05_border_05.txt AC 1 ms 3460 KiB
sample_01.txt AC 1 ms 3376 KiB
sample_02.txt AC 1 ms 3456 KiB
sample_03.txt AC 1 ms 3500 KiB
sample_04.txt AC 1 ms 3584 KiB