Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main(){
long n; scanf("%ld\n", &n);
if(n % 3 == 1){--n;}
else if(n % 3 == 2){++n;}
long feet = n / 36;
long inches = (n - 36 * feet) / 3;
printf("%ld %ld\n", feet, inches);
return 0;
}
Copy The Code &
Try With Live Editor
Input
42
Output
1 2
Demonstration
Codeforces Solution-A. Measuring Lengths in Baden-Solution in C, C++, Java, Python