Jump to content


Check out our Community Blogs

Hacker4life

Member Since 08 Aug 2012
Offline Last Active Sep 21 2012 09:41 AM
-----

Topics I've Started

C graphics

11 September 2012 - 11:09 AM

I have downloaded dev c++ for programming in c. But whenever i use <graphics.h> an error appears, do i have to download some extensions, some more files or what?

Factorial Task

14 August 2012 - 06:08 AM

n! = n*(n-1)*(n-2)....*1

write a program which tells how many ending zero in n!


INPUT:
A single line contains a number N (1<=N<=2000000000)



OUTPUT:
A single line contains a number of ending zero in N!




Input:

18
Output:

3

program zad;
var n,i,s:longint;
k:integer;
begin
read(n);
k:=0;
for i:=2 to n do begin
						 if i mod 5=0 then begin
											 s:=i;
												 repeat
													 k:=k+1;
																 s:=s div 5;
												 until
												 s div 5=0;
														 end;
					 end;
write(k);
end.
My code does not work. Do you have a faster solution ?
It has TLE- time limit exceeded.

String Problem

13 August 2012 - 04:50 AM

The problem, my code fails at some point.
------------------
A. String Task

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
  • deletes all the vowels,
  • inserts a character "." before each consonant,
  • replaces all uppercase consonants with corresponding lowercase ones.
Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string.
Help Petya cope with this easy task.

Input
The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from 1 to 100, inclusive.

Output
Print the resulting string. It is guaranteed that this string is not empty.
Sample test(s)

Input
tour


Output
.t.r


Input
Codeforces


Output
.c.d.f.r.c.s


Input
aBAcAba

Output
.b.c.b
{Code written by Hacker4life
May the Code be with you}
program A118;
var s:string;
i:integer;
begin
readln(s);
s:=LowerCase(s);
i:=1;
while i<length(s) do begin
			   if (s[i]='a')or(s[i]='o')or(s[i]='y')or(s[i]='i')or(s[i]='e')or(s[i]='u') then
									  begin delete(s,i,1); i:=i-1; end;
									  i:=i+1;

						   end;

	 i:=1;
	 repeat
	 insert('.',s,i);
	 i:=i+2;
	 until
	 i>length(s);
write(s);
end.

Example where it fails:
Input: aAaabaAa
my output: .b.a
Whats supposed to be the output: .b
Help?

Just explain this task?

12 August 2012 - 04:41 AM

hi, i really dont know what to do in this task, i tried just to see if the number mod 2=0 then print yes, else no. Just look at the task and plz explain:
--------------------



A. Watermelon

time limit per test1 second

memory limit per test64 megabytes

inputstandard input

outputstandard output

One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.
Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.

Input
The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys.

Output
Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.

Sample test(s)


Input
8


Output
YES


Note
For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos).
-------------------------------------

Prime numbers- code not working, Help?

11 August 2012 - 02:13 AM

Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers!
Input

The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-m<=100000) separated by a space.
Output

For every test case print all prime numbers p such that m <= p <= n, one number per line, test cases separated by an empty line.
----------
{Code written by Hacker4life
May the code be with you}
program zad;
var t,a,b,i,j,k:integer;
q:boolean;
begin
read(t);
for j:=1 to t do begin
read(a,<img src='http://cdn.codecall.net/public/style_emoticons/default/cool.png' class='bbc_emoticon' alt='B)' />;
for i:=a to b do begin
q:=true;
k:=1;
if i>1 then begin
repeat
k:=k+1;
if i mod k=0 then q:=false;
until
(k=i-1)or(q=false);
if i=2 then writeln(2) else
if q then writeln(i); end;
end;
writeln;
end;
end.
some suggestions?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download