UVA 1225 - Digit Counting

UVA Sep 01, 2020

Problem PDF

Solution:

#include
#include
#include
#include
#include
#include
#include
#include
#include 
#include 
#include
#include
#define ll long long
#define sc scanf
#define pf printf
#define Pi 2*acos(0.0)
using namespace std;
int main()
{
    int t;
    sc("%d",&t);
    while(t--)
    {
        mapmp;
        int n;
        sc("%d",&n);
        for(int i=1;i<=n;i++)
        {
            int tp=i;
            while(tp>0)
            {
            mp[tp%10+'0']++;
            tp=tp/10;
            }
        }
        pf("%d %d %d %d %d %d %d %d %d %d\n",mp['0'],mp['1'],mp['2'],
           mp['3'],mp['4'],mp['5'],mp['6'],mp['7'],mp['8'],mp['9']);
    }


    return 0;
}
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/1225/1225.cpp

Tags

Shipu Ahamed

CSPO® | Partly Product, Project Manager and Partly Software Engineer.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.