1 solutions
-
0
C :
#include<stdio.h> int main() { int n; scanf("%d",&n); int i,j; int a[10]={0}; for(i=1;i<=n;i++){ j=i; while(j){ a[j%10]++; j=j/10; } } for(i=0;i<10;i++){ printf("%d\n",a[i]); } return 0; }
C++ :
#include <iostream> using namespace std; int main(){ int n,i,x,s[10]={0}; cin>>n; for(i=1;i<=n;i++){ x=i; while(x!=0){ s[x%10]++; x/=10; } } for(i=0;i<=9;i++){ cout<<s[i]<<endl; } }
Python :
li = [0] * 10 n = int(input()) for i in range(1, n + 1): t = i while t > 0: li[t % 10] += 1 t //= 10 for i in range(0, 10): print(li[i])
- 1
Information
- ID
- 10770
- Time
- 1000ms
- Memory
- 16MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By