| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10806 | Prime number calculator (function) |
|
| 11896 | Check Palindrome (function) |
|
Description
Given a range, you need to count the number of prime numbers in the range.
Note that "1" is not the prime number.
For example:
The range is 1~10
You need to print 4.
Beacuse of there are 4 numbers (2, 3, 5, 7 are the prime numbers) in the range 1~10.
Note that
1. This problem involves three files.
- function.h: Function definition of numPrime.
- function.cpp: Function describe of numPrime.
- main.cpp: A driver program to test your implementation.
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
2. For OJ submission:
Step 1. Submit only your function.cpp into the submission block. (Please choose c++ 11 compiler)
Step 2. Check the results and debug your program if necessary.
function.h
#ifndef FUNCTION_H
#define FUNCTION_H
int numPrime(int start, int end);
#endif
main.cpp
#include <stdio.h>
#include "function.h"
int main(){
int start, end, num;
scanf("%d %d", &start, &end);
num = numPrime(start, end);
printf("%d", num);
return 0;
}
Input
Given the start and end of the range: S E.
Fisrt number S is the start number of the range.
Second number E is the end number of the range.
And the range limit is 1 <= S <= E <= 5000.
For example:
when input is "1 10", it means the range is 1 to 10.
Output
Count the number of prime numbers in the range.
Note that you do not need to print '\n' at the end of the output.
Sample Input Download
Sample Output Download
Partial Judge Code
10806.cppPartial Judge Header
10806.hTags
Discuss
Description
Palindrome is a string that is identical to its reverse, like "level" or "aba". Given a string, check it is palindrome or not.
You are to check all possibile substring (the length of substring is greater than or equal to 2).
NOTE: In the partial code, the function has three parameters: the pointer of the input string, the start position, and the end position.
The range of each substring is from start position to end position (contain the element in the end position).
Input
The input only contains one string. The length of the string is less than 1000.
Output
If the substring is palindrome, print "Yes\n".
If the substring is not palindrome, print "No\n".