Here you will get questions as well as there solutions. we provid you daily with a new question and it's solution. we have codechef and hackerrank solution for beginner now.
Here you will get questions as well as there solutions. we provid you daily with a new question and it's solution. we have codechef and hackerrank solution for beginner now.
Here you will get questions as well as there solutions. we provid you daily with a new question and it's solution. we have codechef and hackerrank solution for beginner now.
Here you will get questions as well as there solutions. we provid you daily with a new question and it's solution. we have codechef and hackerrank solution for beginner now.
Here you will get questions as well as there solutions. we provid you daily with a new question and it's solution. we have codechef and hackerrank solution for beginner now.
The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime.
Input
The input begins with two positive integers n k (n, k<=107). The next n lines of input contain one positive integer ti, not greater than 109, each.
Output
Write a single integer to output, denoting how many integers ti are divisible by k.
Example
Input:
7 3
1
51
966369
7
9
999996
11
Output:
4
solution using c++:-
// Note that this problem is for testing fast input-output.
// We can use scanf, printf in C langauge, which are quite fast in general :)
#include <bits/stdc++.h>
using namespace std;
// Usually, you can use scanf/printf in C++.
// However, if you want to use cin/cout, it is usually slow.
// To make it faster. Use cin.tie(NULL) and set ios_base::sync_with_stdio(false)
// See the below code for details.
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// Read the input n, k
int n, k;
cin >> n >> k;
// ans denotes number of integers n divisible by k
int ans = 0;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
if (t % k == 0) {
ans++;
}
}
// Print the ans.
cout << ans << "\n";
return 0;
}
alternate solution:-
#include <iostream> #include<cstdio> using namespace std; int main() { // Read the input n, k int n, k; scanf("%d %d",&n,&k); // ans denotes number of integers n divisible by k int ans = 0; for (int i = 0; i < n; i++) { int t; scanf("%d",&t); if (t % k == 0) { ans++; } } // Print the ans. printf("%d\n",ans); return 0; }
Objective Today, we're learning and practicing an algorithmic concept called Recursion. Check out the Tutorial tab for learning materials and an instructional video!
Recursive Method for Calculating Factorial
Task
Write a factorial function that takes a positive integer, as a parameter and prints the result of ( factorial).
Note: If you fail to use recursion or fail to name your recursive function factorial or Factorial, you will get a score of .
Input Format
A single integer, (the argument to pass to factorial).
Constraints
Your submission must contain a recursive function named factorial.
Output Format
Print a single integer denoting .
Sample Input
3
Sample Output
6
Explanation
Consider the following steps:
From steps and , we can say ; then when we apply the value from to step , we get . Thus, we print as our answer.