Testing Round #8 A. IQ Test 水题

题目链接:http://codeforces.com/problemset/problem/328/A

这道题目wa了一次,注意这句话:

You should also print 42 if the next element of progression is not integer. So answer is always integer.

然后就可以了。

 1 /*
 2 ID: zypz4571
 3 LANG: C++
 4 TASK: iqtest.cpp
 5  */
 6 
 7 #include <cstdio>
 8 #include <cstdlib>
 9 #include <cstring>
10 #include <cmath>
11 #include <cctype>
12 #include <algorithm>
13 #include <queue>
14 #include <set>
15 #include <queue>
16 #include <list>
17 #include <map>
18 #define INF 0x3f3f3f3f
19 #define mid int m=(l+r)/2
20 using namespace std;
21 int main ( int argc, char *argv[] )
22 {
23 #ifndef ONLINE_JUDGE
24     freopen("in.txt", "r", stdin);
25 #endif
26     int a, b, c, d; scanf("%d%d%d%d", &a,&b,&c,&d);
27     if(b-a==c-b&&c-b==d-c) printf("%d\n",2*d-c);
28     else if (b*b==a*c&&b*d==c*c&&(d*d%c==0)) printf("%d\n",d*d/c);
29     else printf("42\n");
30         return EXIT_SUCCESS;
31 }                /* ----------  end of function main  ---------- */

==

posted on 2013-07-19 00:58  aries__liu  阅读(190)  评论(0编辑  收藏  举报