We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Beautiful Days at the Movies
Beautiful Days at the Movies
navjotahuja92 + 0 comments this :)
i, j, k = [int(x) for x in input().split()] beautifulDays = [1 for day in range(i, j+1) if (day - int(str(day)[::-1])) % k == 0] print(sum(beautifulDays))
patrickdekelly + 0 comments That Lily girl is loony. Get out while you still can Logan! :P
venkatsaikiran + 0 comments Solution in Java
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ Scanner in = new Scanner(System.in); int i = in.nextInt(); int j = in.nextInt(); int k = in.nextInt(); int count = 0; for (int a=i;j>a; a++){ StringBuilder temp = new StringBuilder(); temp.append(a); temp=temp.reverse(); String temp1 = temp.toString(); int aRev = Integer.parseInt(temp1); if(Math.abs((a-aRev)%k)==0){ count++; } } System.out.println(count); } }
Aswath3167 + 0 comments My C Solution......
#include<stdio.h> int main() { int i=0,j=0,k=0,x=0,rem=0,sum=0,count=0; scanf("%d%d%d",&i,&j,&k); for(i;i<=j;i++) { x=i; while(x!=0) { rem=x%10; sum=(sum*10)+rem; x=x/10; } if(abs(i-sum)%k==0) count=count+1; sum=0; } printf("%d",count); return 0; }
daniel_portik + 0 comments My Python3 solution:
def beautifulDays(i, j, k): daycount = int(0) for x in range(i, j+1): if (x - int(str(x)[::-1])) % k == 0: daycount += 1 return daycount
Load more conversations
Sort 1014 Discussions, By:
Please Login in order to post a comment