diff options
Diffstat (limited to '033.c')
| -rw-r--r-- | 033.c | 59 |
1 files changed, 59 insertions, 0 deletions
@@ -0,0 +1,59 @@ + +int curious_fraction(int a, int b) +{ + int a1 = a/10; + int a2 = a%10; + int b1 = b/10; + int b2 = b%10; + + float result = 1.0*a/b; + + if(a2 == 0) + return 0; + + if(a1 == b1) + { + float result2 = 1.0*a2/b2; + if(result == result2) + return 1; + } + + if(a1 == b2) + { + float result2 = 1.0*a2/b1; + if(result == result2) + return 1; + } + + if(a2 == b1) + { + float result2 = 1.0*a1/b2; + if(result == result2) + return 1; + } + + if(a2 == b2) + { + float result2 = 1.0*a1/b1; + if(result == result2) + return 1; + } + + return 0; +} + +int main() +{ + int a, b; + float product = 1.0; + + for(a=10; a<100; a++) + for(b=a+1; b<100; b++) + if(curious_fraction(a, b)) + product *= 1.0*a/b; + + printf("%d\n", (int)(1/product)); + + return 0; +} + |
