Editorial
Use a for loop to print the squares and cubes of all integers from to as required by the problem statement.
Since , it follows that . Use a -bit integer type.
Algorithm realization
Read the input data.
scanf("%lld %lld", &a, &b);
Print the squares of all integers from to inclusive in ascending order.
for (i = a; i <= b; i++) printf("%lld ", i * i); printf("\n");
Print the cubes of all integers from to inclusive in descending order.
for (i = b; i >= a; i--) printf("%lld ", i * i * i); printf("\n");
Java realization
import java.util.*; public class Main { public static void main(String[] args) { Scanner con = new Scanner(System.in); long a = con.nextLong(); long b = con.nextLong(); for(long i = a; i <= b; i++) System.out.print(i*i + " "); System.out.println(); for(long i = b; i >= a; i--) System.out.print(i*i*i + " "); System.out.println(); con.close(); } }
Python realization
Read the input data.
a, b = map(int,input().split())
Print the squares of all integers from to inclusive in ascending order.
for i in range(a,b+1): print(i*i, end = " ") print()
Print the cubes of all integers from to inclusive in descending order.
for i in range(b,a-1,-1): print(i*i*i, end = " ") print()