Problem :
Even Square
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
Brazil
Read an integer N. Print the square of each one of the even values from 1 to N including N if is the case.
Input
The input contain an integer N (5 < N < 2000).
Output
Print the square of each one of the even values from 1 to N, as the given example.
Be carefull! Some language automaticly print 1e+006 instaed 1000000. Please configure your program to print the correct format setting the output precision.
| Sample Input | Sample Output |
| 6 | 2^2 = 4 4^2 = 16 6^2 = 36 |
Solution:
#include<stdio.h>main(){ long long x , i ; scanf("%lld",&x); if(x%2!=0) x-=1; for(i=2; i<=x; i++){ if(i%2==0) printf("%lld^2 = %lld\n",i,i*i); }}
No comments:
Post a Comment