题目链接: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  ---------- */

==

相关文章:

  • 2021-09-05
  • 2021-10-12
  • 2021-07-03
  • 2021-08-07
  • 2021-09-05
  • 2021-06-25
  • 2021-10-27
  • 2021-06-20
猜你喜欢
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案