For reference … I have tried this and it worked for me
import java.lang.;
import java.util.;
class four
{
public static void main(String[] args)
{
Scanner obj= new Scanner(System.in);
int x,z;
x= obj.nextInt();
if ((x>0)&&(x<=100000))
{
int[] y;
y = new int[x];
for(int i=0; i<x; i++)
{
z = obj.nextInt();
int count = 0,a=1,b;
while(a!=0)
{
b = z%10;
if (b==4)
{
count++;
}
a = z/10;
z = a;
}
y[i] = count;
}
for(int j = 0 ; j <x ; j++)
{
System.out.println(y[j]);
}
}
}
Hi,
I am not able to get following line :
(Subtask 1): 0 ≤ Numbers from the list ≤ 9 - 33 points.
(Subtask 2): 0 ≤ Numbers from the list ≤ 109 - 67 points.
i actually managed to receive 33 points so i guess i got Subtask 1, but i am not able to fulfill Subtask 2 although its the same as Sub1 but with different values. Can someone help me ? I am quite new to programming at all so my solution is not that good i guess
Thats what i got so far : (comments are in german, sorry)
I have this C Code which I wrote for this problem. It runs fine and gives me the right answers in my Dev-C++ Environment. But the CodeChef Online Judge says Wrong answer and doesn’t award me points. Can anyone please tell me what is the problem here…??
PS: Code Below
#include <stdio.h>
int main()
{
int T , rem , c , e ;
scanf("%d" , &T) ;
for ( int i = 0 ; i < T ; ++i )
{
scanf("%d" , &e) ;
while (e != 0)
{
rem = e % 10 ;
if (rem == 4)
{
++c ;
}
e = e / 10 ;
}
printf("%d\n" , c) ;
c = 0 ;
}
}
While submitting the solution to the problem, I am getting an error with message “Solution to this problem cannot be submitted now”. Can someone explain that why it is happening so? I am new to the platform.
I don’t understand what I’ve to do under Subtasks 1 and 2. Can someone help me out? I have identified the frequency of 4s present in my numeral and that part works perfectly
int main()
{
int t;
cin>>t;
cin.ignore();
while(t–){
string s;
cin>>s;
int count=0;
for (int i = 0; i < s.size(); ++i)
{
if ((s[i]-‘0’)==4)
{
count=count+1;
}
}