Last active
April 8, 2018 02:36
-
-
Save Mahedi-61/b2cee1ba6175525e923ead4717590075 to your computer and use it in GitHub Desktop.
codeforces problem solution in c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// my solution to problem http://codeforces.com/problemset/problem/897/B | |
#include<stdio.h> | |
#include<math.h> | |
int main(){ | |
int num_digit = 0, remainder = 0; | |
long int num_palindrome, count = 0, n = 0; | |
long long int palindrome = 0, mod = 0, rev_num = 0, arr_sum = 0; | |
scanf("%ld %lld", &num_palindrome, &mod); | |
while(num_palindrome > count){ | |
count++; | |
remainder = 0; | |
rev_num = 0; | |
num_digit = 0; | |
n = count; | |
while(n != 0){ | |
n /= 10; | |
num_digit++; | |
} | |
n = count; | |
while(n != 0){ | |
remainder = n % 10; | |
rev_num = rev_num * 10 + remainder; | |
n /= 10; | |
} | |
palindrome = count * (int)pow(10, num_digit) + rev_num; | |
//printf("%lld", palindrome); | |
//printf(" count: %ld\n", count); | |
arr_sum +=palindrome; | |
}//end of while loop | |
printf("%lld", (arr_sum % mod)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment