Codeforces Round #427 (Div. 2), problem: (B) The number on the board Solution In C/C++

#include <stdio.h>

int k, c, d[10], ans;
main()
{
scanf(“%d”, &k);
getchar();
while ((c = getchar() – ‘0’) >= 0)
d[c]++, k -= c;
for(c = 0; k > 0; d[c] ? d[c]– : c++)
if(d[c])
ans++, k -= 9 – c;
printf(“%d\n”, ans);
return 0;
}

#include <stdio.h>

int k, c, d[10], ans;
main()
{
scanf(“%d”, &k);
getchar();
while ((c = getchar() – ‘0’) >= 0)
d[c]++, k -= c;
for(c = 0; k > 0; d[c] ? d[c]– : c++)
if(d[c])
ans++, k -= 9 – c;
printf(“%d\n”, ans);
return 0;
}

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

What does rat scat look like?

Discovering unwanted pests in your living space is a homeowner's worst nightmare. Among the clearest signals of a rodent problem is finding fecal matter...

How to Use Snail Mucin Essence on Face (Complete Beginner’s Guide)

Overview: How to Use Snail Mucin Essence on Face (Complete Beginner's Guide) Finding reliable, data-backed guidance on how to use snail mucin essence on face...

How to Use Cosrx Snail Mucin at Night (Complete Beginner’s Guide)

Overview: How to Use Cosrx Snail Mucin at Night (Complete Beginner's Guide) Finding reliable, data-backed guidance on how to use cosrx snail mucin at night...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!