fork(7) download
  1. // div2c
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. int main() {
  5. int n, d, h;
  6. scanf("%d%d%d", &n, &d, &h);
  7. if(d > 2 * h || (d == 1 && n != 2)) {
  8. puts("-1");
  9. return 0;
  10. }
  11. for(int i = 1; i <= h; ++i)
  12. printf("%d %d\n", i, i + 1);
  13. int x = 1;
  14. for(int i = 1; i <= d - h; ++i) {
  15. int y = h + 1 + i;
  16. printf("%d %d\n", x, y);
  17. x = y;
  18. }
  19. for(int i = d + 2; i <= n; ++i)
  20. printf("%d %d\n", i, (d == h) ? 2 : 1);
  21. return 0;
  22. }
  23.  
  24. // div2d
  25. #include<bits/stdc++.h>
  26. using namespace std;
  27. typedef long long ll;
  28. const int nax = 1e6 + 5;
  29. int t[nax];
  30. ll pref[nax], suf[nax];
  31. const ll WRONG = 1e16 + 5;
  32.  
  33. int main() {
  34. int n, k;
  35. scanf("%d%d", &n, &k);
  36. for(int i = 0; i <= n; ++i)
  37. scanf("%d", &t[i]);
  38. for(int i = 0; i < n; ++i) {
  39. pref[i+1] = pref[i] + t[i];
  40. if(pref[i+1] % 2) {
  41. for(int j = i + 1; j <= n; ++j)
  42. pref[j] = WRONG;
  43. break;
  44. }
  45. else
  46. pref[i+1] /= 2;
  47. }
  48. for(int i = n; i > 0; --i) {
  49. suf[i-1] = suf[i] + t[i];
  50. suf[i-1] *= 2;
  51. if(abs(suf[i-1]) >= WRONG) {
  52. for(int j = i - 1; j >= 0; --j)
  53. suf[j] = WRONG;
  54. break;
  55. }
  56. }
  57. int ans = 0;
  58. for(int i = 0; i <= n; ++i)
  59. if(suf[i] != WRONG && pref[i] != WRONG) {
  60. long long maybe = -(pref[i] + suf[i]);
  61. if(maybe == 0 && i == n) continue;
  62. if(abs(maybe) <= k)
  63. ++ans;
  64. }
  65. printf("%d\n", ans);
  66. return 0;
  67. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:33:5: error: redefinition of 'int main()'
 int main() {
     ^
prog.cpp:4:5: note: 'int main()' previously defined here
 int main() {
     ^
stdout
Standard output is empty