eolymp
bolt
Try our new interface for solving problems
Problems

Кількість n-значних чисел

published at 12/11/22, 7:57:35 am

SIMON RILEY CODM

published at 2/7/24, 8:30:30 pm

include <bits/stdc++.h>

using namespace std; int main() { long n,m; cin>>n>>m;

long n1=pow(10,n-1)-pow(10,n-2); if(m>=n1){ long m1=m-n1-1; cout<<m1;

}

else cout<<0;

} // why is this 20%

published at 2/21/24, 8:01:06 pm

include<bits/stdc++.h>

define ll long long

using namespace std; int main() {

ll n, m, ans = 0; 
cin >> n >> m;
ll x = m;
while(x > 0) { 
    ans++; 
    x/=10; 
} 
if(n == ans) 
    cout << m - pow(10, n-1); 
if(n < ans) { 
    cout << pow(10, n) - pow(10, n-1); 
} 
if(n > ans) 
    cout << 0;

}