diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:21:45 +0200 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:35:09 +0200 |
| commit | 95341b61b030c9e1290f3b326cb7ec584f543aea (patch) | |
| tree | 852386fa04d32eb859bca11c0eff7b5ef9e50f00 /033.c | |
| parent | 571164d977f91925c4c76a292f74f5f93d09ae23 (diff) | |
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; +} + |
