Disclaimer: Make sure you tried enough before checking the solution
Problem: https://codeforces.com/group/MWSDmqGsZm/contest/219774/problem/N
#include<stdio.h> #include<string.h> int main(){ int a,b,i; scanf("%d%d",&a,&b); char c[1000]; scanf("%s",c); //check if - exists if(c[a]!='-'){ printf("No"); return 0; } //check if of the value if(a+b+1 !=strlen(c)){ printf("No"); return 0 ; } int ct = 0; for(i=0;i<strlen(c);i++){ if(c[i]>=48 && c[i]<=57){ ct++; } } if(ct==a+b)printf("Yes"); else printf("No"); return 0; }
Assiut University Training – Newcomers Solution Array