From 95341b61b030c9e1290f3b326cb7ec584f543aea Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 31 Aug 2014 20:21:45 +0200 Subject: moved files to higher directory after split to new repository --- 033.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 033.c (limited to '033.c') diff --git a/033.c b/033.c new file mode 100644 index 0000000..61a7ffd --- /dev/null +++ b/033.c @@ -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; +} + -- cgit v1.2.3